Add templates Tox + SonarQube Jenkins plugin
[releng/global-jjb.git] / jjb / lf-python-jobs.yaml
1 ---
2 ##########
3 # Macros #
4 ##########
5
6 - builder:
7     name: lf-infra-clm-python
8     builders:
9       - inject:
10           properties-content: "CLM_PROJECT_NAME={clm-project-name}"
11       - shell: !include-raw-escape: ../shell/nexus-iq-cli.sh
12
13 - builder:
14     name: lf-infra-tox-install
15     builders:
16       - inject:
17           properties-content: "PYTHON={python-version}"
18       - shell: !include-raw-escape: ../shell/tox-install.sh
19
20 - builder:
21     name: lf-infra-tox-run
22     builders:
23       - inject:
24           properties-content: "PARALLEL={parallel}"
25       - shell: !include-raw-escape: ../shell/tox-run.sh
26
27 ####################
28 # COMMON FUNCTIONS #
29 ####################
30
31 - lf_python_common: &lf_python_common
32     name: lf-python-common
33
34     ######################
35     # Default parameters #
36     ######################
37
38     archive-artifacts: >
39       **/*.log
40
41     #####################
42     # Job Configuration #
43     #####################
44
45     project-type: freestyle
46     node: "{build-node}"
47
48     properties:
49       - lf-infra-properties:
50           build-days-to-keep: "{build-days-to-keep}"
51
52     parameters:
53       - lf-infra-parameters:
54           project: "{project}"
55           branch: "{branch}"
56           stream: "{stream}"
57
58     wrappers:
59       - lf-infra-wrappers:
60           build-timeout: "{build-timeout}"
61           jenkins-ssh-credential: "{jenkins-ssh-credential}"
62
63     publishers:
64       - lf-infra-publish
65
66 #################
67 # Python XC CLM #
68 #################
69
70 - lf_python_clm_xc: &lf_python_xc_clm
71     name: lf-python-xc-clm
72
73     ######################
74     # Default parameters #
75     ######################
76
77     branch: master
78     build-days-to-keep: 30 # 30 days for troubleshooting purposes
79     build-timeout: 60
80     disable-job: false
81     git-url: "$GIT_URL/$PROJECT"
82     github-url: "https://github.com"
83     java-version: openjdk8
84     nexus-iq-cli-version: 1.44.0-01
85     nexus-iq-namespace: "" # Recommend a trailing dash when set. Example: odl-
86     pre-build-script: "  # pre-build script goes here"
87     stream: master
88     submodule-recursive: true
89     submodule-timeout: 10
90     submodule-disable: false
91
92     gerrit_trigger_file_paths:
93       - compare-type: REG_EXP
94         pattern: ".*"
95
96     # github_included_regions MUST match gerrit_trigger_file_paths
97     github_included_regions:
98       - ".*"
99
100     #####################
101     # Job Configuration #
102     #####################
103
104     disabled: "{disable-job}"
105
106     parameters:
107       - lf-infra-parameters:
108           project: "{project}"
109           branch: "{branch}"
110           stream: "{stream}"
111       - string:
112           name: NEXUS_IQ_CLI_VERSION
113           default: "{nexus-iq-cli-version}"
114           description: Nexus IQ CLI package to download and use.
115
116     wrappers:
117       - credentials-binding:
118           - username-password-separated:
119               credential-id: nexus-iq-xc-clm
120               username: CLM_USER
121               password: CLM_PASSWORD
122     builders:
123       - lf-update-java-alternatives:
124           java-version: "{java-version}"
125       - shell: "{pre-build-script}"
126       - lf-infra-clm-python:
127           clm-project-name: "{nexus-iq-namespace}{project-name}"
128
129 - job-template:
130     name: "{project-name}-python-clm-{stream}"
131     id: gerrit-python-xc-clm
132     <<: *lf_python_common
133     <<: *lf_python_xc_clm
134
135     ######################
136     # Default parameters #
137     ######################
138
139     gerrit_clm_triggers:
140       - comment-added-contains-event:
141           comment-contains-value: '^Patch Set\s+\d+:\s+run-clm\s*$'
142
143     #####################
144     # Job Configuration #
145     #####################
146
147     scm:
148       - lf-infra-gerrit-scm:
149           jenkins-ssh-credential: "{jenkins-ssh-credential}"
150           git-url: "{git-url}"
151           refspec: "$GERRIT_REFSPEC"
152           branch: "$GERRIT_BRANCH"
153           submodule-recursive: "{submodule-recursive}"
154           submodule-timeout: "{submodule-timeout}"
155           submodule-disable: "{submodule-disable}"
156           choosing-strategy: default
157
158     triggers:
159       # Build weekly on Saturdays
160       - timed: "H H * * 6"
161       - gerrit:
162           server-name: "{gerrit-server-name}"
163           trigger-on: "{obj:gerrit_clm_triggers}"
164           projects:
165             - project-compare-type: ANT
166               project-pattern: "{project}"
167               branches:
168                 - branch-compare-type: ANT
169                   branch-pattern: "**/{branch}"
170               file-paths: "{obj:gerrit_trigger_file_paths}"
171           skip-vote:
172             successful: true
173             failed: true
174             unstable: true
175             notbuilt: true
176
177 - job-template:
178     name: "{project-name}-python-clm-{stream}"
179     id: github-python-xc-clm
180     <<: *lf_python_common
181     <<: *lf_python_xc_clm
182
183     properties:
184       - lf-infra-properties:
185           build-days-to-keep: "{build-days-to-keep}"
186       - github:
187           url: "{github-url}/{github-org}/{project}"
188
189     scm:
190       - lf-infra-github-scm:
191           url: "{git-clone-url}{github-org}/{project}"
192           refspec: ""
193           branch: "refs/heads/{branch}"
194           submodule-recursive: "{submodule-recursive}"
195           submodule-timeout: "{submodule-timeout}"
196           submodule-disable: "{submodule-disable}"
197           choosing-strategy: default
198           jenkins-ssh-credential: "{jenkins-ssh-credential}"
199
200     triggers:
201       # Build weekly on Saturdays
202       - timed: "H H * * 6"
203       - github-pull-request:
204           trigger-phrase: "^run-clm$"
205           only-trigger-phrase: false
206           status-context: "CLM"
207           permit-all: true
208           github-hooks: true
209           white-list-target-branches:
210             - "{branch}"
211           included-regions: "{obj:github_included_regions}"
212
213 #########################
214 # Python Sonar with Tox #
215 #########################
216
217 - lf_tox_sonar: &lf_tox_sonar
218     name: lf-tox-sonar
219
220     ######################
221     # Default parameters #
222     ######################
223
224     branch: master # Sonar should always be run on master branch
225     build-days-to-keep: 7
226     build-timeout: 60
227     cron: "H H * * *" # run daily
228     disable-job: false
229     git-url: "$GIT_URL/$PROJECT"
230     github-url: "https://github.com"
231     java-version: openjdk8
232     mvn-global-settings: global-settings
233     mvn-goals: validate
234     mvn-opts: ""
235     mvn-params: ""
236     mvn-settings: "{mvn-settings}"
237     mvn-version: mvn35
238     parallel: true
239     pre-build-script: "# pre-build script goes here"
240     python-version: python3
241     sonar-mvn-goal: "sonar:sonar"
242     sonarcloud: false
243     sonarcloud-project-key: ""
244     sonarcloud-project-organization: ""
245     sonarcloud-api-token: ""
246     stream: master
247     submodule-recursive: true
248     submodule-timeout: 10
249     submodule-disable: false
250     tox-dir: "."
251     tox-envs: ""
252
253     gerrit_trigger_file_paths:
254       - compare-type: REG_EXP
255         pattern: ".*"
256
257     # github_included_regions MUST match gerrit_trigger_file_paths
258     github_included_regions:
259       - ".*"
260
261     #####################
262     # Job Configuration #
263     #####################
264
265     disabled: "{disable-job}"
266
267     parameters:
268       - lf-infra-parameters:
269           project: "{project}"
270           branch: "{branch}"
271           stream: "{stream}"
272       - lf-infra-maven-parameters:
273           mvn-opts: "{mvn-opts}"
274           mvn-params: "{mvn-params}"
275           mvn-version: "{mvn-version}"
276       - lf-infra-tox-parameters:
277           tox-dir: "{tox-dir}"
278           tox-envs: "{tox-envs}"
279       - string:
280           name: ARCHIVE_ARTIFACTS
281           default: "{archive-artifacts}"
282           description: Artifacts to archive to the logs server.
283       - string:
284           name: MVN
285           # Sets an env var for shell scripts to be able to call the dynamically
286           # installed maven without having to calculate the path themselves.
287           # yamllint disable-line rule:line-length
288           default: "/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn"
289           description: "Maven selector to be used by shell scripts"
290       - string:
291           name: SONAR_MAVEN_GOAL
292           default: "{sonar-mvn-goal}"
293           description: |
294             Maven goals to pass to the Sonar call. Typically sonar:sonar
295             however to use a specific version of the sonar-maven-plugin we
296             can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
297
298     builders:
299       - lf-infra-pre-build
300       - lf-infra-tox-install:
301           python-version: "{python-version}"
302       - shell: "{pre-build-script}"
303       - lf-infra-tox-run:
304           parallel: "{parallel}"
305       - lf-provide-maven-settings:
306           global-settings-file: "{mvn-global-settings}"
307           settings-file: "{mvn-settings}"
308       # With SonarCloud
309       - conditional-step:
310           condition-kind: boolean-expression
311           condition-expression: "{sonarcloud}"
312           steps:
313             - shell: echo 'Using SonarCloud'
314             - lf-infra-maven-sonarcloud:
315                 java-version: "{java-version}"
316                 mvn-goals: "{mvn-goals}"
317                 mvn-settings: "{mvn-settings}"
318                 mvn-version: "{mvn-version}"
319                 sonarcloud-project-key: "{sonarcloud-project-key}"
320                 # yamllint disable-line rule:line-length
321                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
322                 sonarcloud-api-token: "{sonarcloud-api-token}"
323       # With SonarQube
324       - conditional-step:
325           condition-kind: not
326           condition-operand:
327             condition-kind: boolean-expression
328             condition-expression: "{sonarcloud}"
329           steps:
330             - shell: echo 'Using SonarQube'
331             - lf-infra-maven-sonar:
332                 java-version: "{java-version}"
333                 mvn-goals: "{mvn-goals}"
334                 mvn-settings: "{mvn-settings}"
335                 mvn-version: "{mvn-version}"
336
337     publishers:
338       - lf-infra-publish
339
340 - job-template:
341     name: "{project-name}-tox-sonar"
342     id: gerrit-tox-sonar
343     <<: *lf_python_common
344     <<: *lf_tox_sonar
345
346     ######################
347     # Default parameters #
348     ######################
349
350     gerrit_sonar_triggers:
351       - comment-added-contains-event:
352           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
353
354     #####################
355     # Job Configuration #
356     #####################
357
358     scm:
359       - lf-infra-gerrit-scm:
360           jenkins-ssh-credential: "{jenkins-ssh-credential}"
361           git-url: "{git-url}"
362           refspec: $GERRIT_REFSPEC
363           branch: $GERRIT_BRANCH
364           submodule-recursive: "{submodule-recursive}"
365           submodule-timeout: "{submodule-timeout}"
366           submodule-disable: "{submodule-disable}"
367           choosing-strategy: default
368
369     triggers:
370       - timed: "{obj:cron}"
371       - gerrit:
372           server-name: "{gerrit-server-name}"
373           trigger-on: "{obj:gerrit_sonar_triggers}"
374           projects:
375             - project-compare-type: "ANT"
376               project-pattern: "{project}"
377               branches:
378                 - branch-compare-type: "ANT"
379                   branch-pattern: "**/{branch}"
380               file-paths: "{obj:gerrit_trigger_file_paths}"
381           skip-vote:
382             successful: true
383             failed: true
384             unstable: true
385             notbuilt: true
386
387 - job-template:
388     name: "{project-name}-tox-sonar"
389     id: github-tox-sonar
390     <<: *lf_python_common
391     <<: *lf_tox_sonar
392
393     properties:
394       - lf-infra-properties:
395           build-days-to-keep: "{build-days-to-keep}"
396       - github:
397           url: "{github-url}/{github-org}/{project}"
398
399     scm:
400       - lf-infra-github-scm:
401           url: "{git-clone-url}{github-org}/{project}"
402           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
403           branch: "$sha1"
404           submodule-recursive: "{submodule-recursive}"
405           submodule-timeout: "{submodule-timeout}"
406           submodule-disable: "{submodule-disable}"
407           choosing-strategy: default
408           jenkins-ssh-credential: "{jenkins-ssh-credential}"
409
410     triggers:
411       - github-pull-request:
412           trigger-phrase: "^run-sonar$"
413           only-trigger-phrase: false
414           status-context: "Python Sonar"
415           permit-all: true
416           github-hooks: true
417           white-list-target-branches:
418             - "{branch}"
419           included-regions: "{obj:github_included_regions}"
420
421 #################
422 # Tox SonarQube #
423 #################
424
425 - lf_tox_sonarqube: &lf_tox_sonarqube
426     name: lf-tox-sonarqube
427
428     ######################
429     # Default parameters #
430     ######################
431
432     archive-artifacts: >
433       **/*.log
434     branch: master # Sonar should always be run on master branch
435     build-days-to-keep: 7
436     build-timeout: 15
437     cron: "@weekly"
438     disable-job: false
439     git-url: "$GIT_URL/$PROJECT"
440     github-url: "https://github.com"
441     parallel: false
442     pre-build-script: "# pre-build script goes here"
443     python-version: python3
444     stream: master
445     submodule-recursive: true
446     submodule-timeout: 10
447     submodule-disable: false
448     tox-dir: "."
449     tox-envs: ""
450     # Sonar properties
451     sonar-additional-args: ""
452     sonar-java-opts: ""
453     sonar-project-file: "sonar-project.properties"
454     sonar-properties: ""
455     sonar-task: ""
456
457     #####################
458     # Job Configuration #
459     #####################
460
461     project-type: freestyle
462     node: "{build-node}"
463     disabled: "{disable-job}"
464
465     properties:
466       - lf-infra-properties:
467           build-days-to-keep: "{build-days-to-keep}"
468
469     wrappers:
470       - lf-infra-wrappers:
471           build-timeout: "{build-timeout}"
472           jenkins-ssh-credential: "{jenkins-ssh-credential}"
473
474     parameters:
475       - lf-infra-parameters:
476           project: "{project}"
477           branch: "{branch}"
478           stream: "{stream}"
479       - lf-infra-tox-parameters:
480           tox-dir: "{tox-dir}"
481           tox-envs: "{tox-envs}"
482       - string:
483           name: ARCHIVE_ARTIFACTS
484           default: "{archive-artifacts}"
485           description: Artifacts to archive to the logs server.
486
487     builders:
488       - lf-infra-pre-build
489       - lf-infra-tox-install:
490           python-version: "{python-version}"
491       - shell: "{pre-build-script}"
492       - lf-infra-tox-run:
493           parallel: "{parallel}"
494       - lf-infra-sonar:
495           sonar-task: "{sonar-task}"
496           sonar-project-file: "{sonar-project-file}"
497           sonar-properties: "{sonar-properties}"
498           sonar-java-opts: "{sonar-java-opts}"
499           sonar-additional-args: "{sonar-additional-args}"
500
501     publishers:
502       - lf-infra-publish
503
504 - job-template:
505     name: "{project-name}-tox-sonarqube"
506     id: gerrit-tox-sonarqube
507     concurrent: false
508     <<: *lf_tox_sonarqube
509
510     scm:
511       - lf-infra-gerrit-scm:
512           branch: "$GERRIT_BRANCH"
513           jenkins-ssh-credential: "{jenkins-ssh-credential}"
514           git-url: "{git-url}"
515           refspec: "$GERRIT_REFSPEC"
516           submodule-recursive: "{submodule-recursive}"
517           submodule-timeout: "{submodule-timeout}"
518           submodule-disable: "{submodule-disable}"
519           choosing-strategy: default
520
521     triggers:
522       - timed: "{obj:cron}"
523       - gerrit:
524           server-name: "{gerrit-server-name}"
525           trigger-on:
526             - comment-added-contains-event:
527                 comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
528           projects:
529             - project-compare-type: "ANT"
530               project-pattern: "{project}"
531               branches:
532                 - branch-compare-type: "ANT"
533                   branch-pattern: "**/{branch}"
534
535 - job-template:
536     name: "{project-name}-tox-sonarqube"
537     id: github-tox-sonarqube
538     concurrent: false
539     <<: *lf_tox_sonarqube
540
541     scm:
542       - lf-infra-github-scm:
543           branch: "$sha1"
544           jenkins-ssh-credential: "{jenkins-ssh-credential}"
545           url: "{git-clone-url}{github-org}/{project}"
546           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
547           submodule-recursive: "{submodule-recursive}"
548           submodule-timeout: "{submodule-timeout}"
549           submodule-disable: "{submodule-disable}"
550           choosing-strategy: default
551
552     triggers:
553       - github-pull-request:
554           trigger-phrase: "^run-sonar$"
555           only-trigger-phrase: false
556           status-context: "Tox Sonarqube"
557           permit-all: true
558           github-hooks: true
559           white-list-target-branches:
560             - "{branch}"
561
562 ##############
563 # Tox Common #
564 ##############
565
566 - lf_tox_common: &lf_tox_common
567     name: lf-tox-common
568
569     ######################
570     # Default parameters #
571     ######################
572
573     branch: master
574     build-days-to-keep: 7
575     build-timeout: 15
576     disable-job: false
577     git-url: "$GIT_URL/$GERRIT_PROJECT"
578     github-url: "https://github.com"
579     parallel: false
580     pre-build-script: "# pre-build script goes here"
581     python-version: python3
582     stream: master
583     submodule-recursive: true
584     submodule-timeout: 10
585     submodule-disable: false
586     tox-dir: "."
587     tox-envs: ""
588
589     gerrit_trigger_file_paths:
590       - compare-type: REG_EXP
591         pattern: ".*"
592
593     # github_included_regions MUST match gerrit_trigger_file_paths
594     github_included_regions:
595       - ".*"
596
597     #####################
598     # Job Configuration #
599     #####################
600
601     project-type: freestyle
602     node: "{build-node}"
603     concurrent: true
604     disabled: "{disable-job}"
605
606     properties:
607       - lf-infra-properties:
608           build-days-to-keep: "{build-days-to-keep}"
609
610     parameters:
611       - lf-infra-parameters:
612           project: "{project}"
613           branch: "{branch}"
614           stream: "{stream}"
615       - lf-infra-tox-parameters:
616           tox-dir: "{tox-dir}"
617           tox-envs: "{tox-envs}"
618
619     wrappers:
620       - lf-infra-wrappers:
621           build-timeout: "{build-timeout}"
622           jenkins-ssh-credential: "{jenkins-ssh-credential}"
623
624     builders:
625       - lf-infra-pre-build
626       - lf-infra-tox-install:
627           python-version: "{python-version}"
628       - shell: "{pre-build-script}"
629       - lf-infra-tox-run:
630           parallel: "{parallel}"
631
632     publishers:
633       - lf-infra-publish
634
635 - job-template:
636     # Python projects typically use tox to run testing.
637     name: "{project-name}-tox-verify-{stream}"
638     id: gerrit-tox-verify
639     <<: *lf_tox_common
640
641     ######################
642     # Default parameters #
643     ######################
644
645     gerrit-skip-vote: false
646     gerrit_verify_triggers:
647       - patchset-created-event:
648           exclude-drafts: true
649           exclude-trivial-rebase: false
650           exclude-no-code-change: false
651       - draft-published-event
652       - comment-added-contains-event:
653           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
654
655     #####################
656     # Job Configuration #
657     #####################
658
659     scm:
660       - lf-infra-gerrit-scm:
661           jenkins-ssh-credential: "{jenkins-ssh-credential}"
662           git-url: "{git-url}"
663           refspec: "$GERRIT_REFSPEC"
664           branch: "$GERRIT_BRANCH"
665           submodule-recursive: "{submodule-recursive}"
666           submodule-timeout: "{submodule-timeout}"
667           submodule-disable: "{submodule-disable}"
668           choosing-strategy: gerrit
669
670     triggers:
671       - gerrit:
672           server-name: "{gerrit-server-name}"
673           trigger-on: "{obj:gerrit_verify_triggers}"
674           projects:
675             - project-compare-type: ANT
676               project-pattern: "{project}"
677               branches:
678                 - branch-compare-type: ANT
679                   branch-pattern: "**/{branch}"
680               file-paths: "{obj:gerrit_trigger_file_paths}"
681           skip-vote:
682             successful: "{gerrit-skip-vote}"
683             failed: "{gerrit-skip-vote}"
684             unstable: "{gerrit-skip-vote}"
685             notbuilt: "{gerrit-skip-vote}"
686
687 - job-template:
688     # Python projects typically use tox to run testing.
689     name: "{project-name}-tox-verify-{stream}"
690     id: github-tox-verify
691     <<: *lf_tox_common
692
693     properties:
694       - lf-infra-properties:
695           build-days-to-keep: "{build-days-to-keep}"
696       - github:
697           url: "{github-url}/{github-org}/{project}"
698
699     scm:
700       - lf-infra-github-scm:
701           url: "{git-clone-url}{github-org}/{project}"
702           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
703           branch: "$sha1"
704           submodule-recursive: "{submodule-recursive}"
705           submodule-timeout: "{submodule-timeout}"
706           submodule-disable: "{submodule-disable}"
707           choosing-strategy: default
708           jenkins-ssh-credential: "{jenkins-ssh-credential}"
709
710     triggers:
711       - github-pull-request:
712           trigger-phrase: "^(recheck|reverify)$"
713           only-trigger-phrase: false
714           status-context: "Tox Verify"
715           permit-all: true
716           github-hooks: true
717           white-list-target-branches:
718             - "{branch}"
719           included-regions: "{obj:github_included_regions}"
720
721 - job-template:
722     # Run tox after merge of gerrit change set
723     name: "{project-name}-tox-merge-{stream}"
724     id: gerrit-tox-merge
725     <<: *lf_tox_common
726
727     ######################
728     # Default parameters #
729     ######################
730
731     gerrit_merge_triggers:
732       - change-merged-event
733       - comment-added-contains-event:
734           comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
735
736     #####################
737     # Job Configuration #
738     #####################
739
740     scm:
741       - lf-infra-gerrit-scm:
742           jenkins-ssh-credential: "{jenkins-ssh-credential}"
743           git-url: "{git-url}"
744           refspec: "$GERRIT_REFSPEC"
745           branch: "$GERRIT_BRANCH"
746           submodule-recursive: "{submodule-recursive}"
747           submodule-timeout: "{submodule-timeout}"
748           submodule-disable: "{submodule-disable}"
749           # merge jobs always build from tip
750           choosing-strategy: default
751
752     triggers:
753       - gerrit:
754           server-name: "{gerrit-server-name}"
755           trigger-on: "{obj:gerrit_merge_triggers}"
756           projects:
757             - project-compare-type: ANT
758               project-pattern: "{project}"
759               branches:
760                 - branch-compare-type: ANT
761                   branch-pattern: "**/{branch}"
762               file-paths: "{obj:gerrit_trigger_file_paths}"
763
764 - job-template:
765     # Run tox after merge of github pull request
766     name: "{project-name}-tox-merge-{stream}"
767     id: github-tox-merge
768     <<: *lf_tox_common
769
770     properties:
771       - lf-infra-properties:
772           build-days-to-keep: "{build-days-to-keep}"
773       - github:
774           url: "{github-url}/{github-org}/{project}"
775
776     scm:
777       - lf-infra-github-scm:
778           url: "{git-clone-url}{github-org}/{project}"
779           refspec: ""
780           branch: "refs/heads/{branch}"
781           submodule-recursive: "{submodule-recursive}"
782           submodule-timeout: "{submodule-timeout}"
783           submodule-disable: "{submodule-disable}"
784           choosing-strategy: default
785           jenkins-ssh-credential: "{jenkins-ssh-credential}"
786
787     triggers:
788       - github-pull-request:
789           trigger-phrase: "^remerge$"
790           only-trigger-phrase: true
791           status-context: "Tox Merge"
792           permit-all: true
793           github-hooks: true
794           org-list:
795             - "{github-org}"
796           white-list: "{obj:github_pr_whitelist}"
797           admin-list: "{obj:github_pr_admin_list}"
798           white-list-target-branches:
799             - "{branch}"
800           included-regions: "{obj:github_included_regions}"
801
802 ########
803 # PyPI #
804 ########
805
806 - lf_pypi_common: &lf_pypi_common
807     name: lf-pypi-common
808
809     ######################
810     # Default parameters #
811     ######################
812
813     archive-artifacts: >
814       **/*.log
815     branch: master
816     build-days-to-keep: 7
817     build-timeout: 15
818     disable-job: false
819     dist-binary: true
820     git-url: "$GIT_URL/$GERRIT_PROJECT"
821     github-url: "https://github.com"
822     parallel: false
823     pre-build-script: "# pre-build script goes here"
824     python-version: python3
825     stream: master
826     submodule-disable: false
827     submodule-recursive: true
828     submodule-timeout: 10
829     tox-dir: "."
830     tox-envs: ""
831
832     gerrit_trigger_file_paths:
833       - compare-type: REG_EXP
834         pattern: ".*"
835
836     # github_included_regions MUST match gerrit_trigger_file_paths
837     github_included_regions:
838       - ".*"
839
840     #####################
841     # Job Configuration #
842     #####################
843
844     project-type: freestyle
845     node: "{build-node}"
846     disabled: "{disable-job}"
847
848     properties:
849       - lf-infra-properties:
850           build-days-to-keep: "{build-days-to-keep}"
851
852     parameters:
853       - lf-infra-parameters:
854           project: "{project}"
855           branch: "{branch}"
856           stream: "{stream}"
857       - lf-infra-tox-parameters:
858           tox-dir: "{tox-dir}"
859           tox-envs: "{tox-envs}"
860       - bool:
861           name: BUILD_BDIST_WHEEL
862           default: "{dist-binary}"
863           description: "Set to True (checked) to build a binary distribution"
864       - bool:
865           name: DRY_RUN
866           default: false
867           description: "Set to True (checked) to skip uploading artifacts"
868
869     wrappers:
870       - lf-infra-wrappers:
871           build-timeout: "{build-timeout}"
872           jenkins-ssh-credential: "{jenkins-ssh-credential}"
873
874     publishers:
875       - lf-infra-publish
876
877 - lf_pypi_verify_builders: &lf_pypi_verify_builders
878     name: lf-pypi-verify-builders
879
880     builders:
881       - lf-infra-pre-build
882       - lf-infra-tox-install:
883           python-version: "{python-version}"
884       - shell: "{pre-build-script}"
885       - lf-infra-tox-run:
886           parallel: "{parallel}"
887       - shell: !include-raw-escape: ../shell/pypi-dist-build.sh
888
889 - lf_pypi_merge_builders: &lf_pypi_merge_builders
890     name: lf-pypi-merge-builders
891
892     builders:
893       - lf-infra-pre-build
894       - lf-infra-tox-install:
895           python-version: "{python-version}"
896       - shell: "{pre-build-script}"
897       - lf-infra-tox-run:
898           parallel: "{parallel}"
899       - shell: !include-raw-escape: ../shell/pypi-dist-build.sh
900       - config-file-provider:
901           files:
902             - file-id: pypirc
903               target: "$HOME/.pypirc"
904       - inject:
905           properties-content: "REPOSITORY={pypi-repo}"
906       - shell: !include-raw-escape: ../shell/pypi-upload.sh
907
908 - job-template:
909     name: "{project-name}-pypi-verify-{stream}"
910     id: gerrit-pypi-verify
911     <<: *lf_pypi_common
912     <<: *lf_pypi_verify_builders
913
914     scm:
915       - lf-infra-gerrit-scm:
916           jenkins-ssh-credential: "{jenkins-ssh-credential}"
917           git-url: "{git-url}"
918           refspec: "$GERRIT_REFSPEC"
919           branch: "$GERRIT_BRANCH"
920           submodule-recursive: "{submodule-recursive}"
921           submodule-timeout: "{submodule-timeout}"
922           submodule-disable: "{submodule-disable}"
923           choosing-strategy: gerrit
924
925     triggers:
926       - gerrit:
927           server-name: "{gerrit-server-name}"
928           trigger-on:
929             - patchset-created-event:
930                 exclude-drafts: true
931                 exclude-trivial-rebase: false
932                 exclude-no-code-change: false
933             - draft-published-event
934             - comment-added-contains-event:
935                 # yamllint disable-line rule:line-length
936                 comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
937           projects:
938             - project-compare-type: ANT
939               project-pattern: "{project}"
940               branches:
941                 - branch-compare-type: ANT
942                   branch-pattern: "**/{branch}"
943               file-paths: "{obj:gerrit_trigger_file_paths}"
944
945 - job-template:
946     name: "{project-name}-pypi-verify-{stream}"
947     id: github-pypi-verify
948     <<: *lf_pypi_common
949     <<: *lf_pypi_verify_builders
950
951     properties:
952       - github:
953           url: "{github-url}/{github-org}/{project}"
954
955     scm:
956       - lf-infra-github-scm:
957           url: "{git-clone-url}{github-org}/{project}"
958           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
959           branch: "$sha1"
960           submodule-recursive: "{submodule-recursive}"
961           submodule-timeout: "{submodule-timeout}"
962           submodule-disable: "{submodule-disable}"
963           choosing-strategy: default
964           jenkins-ssh-credential: "{jenkins-ssh-credential}"
965
966     triggers:
967       - github-pull-request:
968           trigger-phrase: "^(recheck|reverify)$"
969           only-trigger-phrase: false
970           status-context: "PyPI Verify"
971           permit-all: true
972           github-hooks: true
973           white-list-target-branches:
974             - "{branch}"
975           included-regions: "{obj:github_included_regions}"
976
977 - job-template:
978     name: "{project-name}-pypi-merge-{stream}"
979     id: gerrit-pypi-merge
980     <<: *lf_pypi_common
981     <<: *lf_pypi_merge_builders
982
983     cron: ""
984     pypi-repo: pypi-test
985
986     scm:
987       - lf-infra-gerrit-scm:
988           jenkins-ssh-credential: "{jenkins-ssh-credential}"
989           git-url: "{git-url}"
990           refspec: "$GERRIT_REFSPEC"
991           branch: "$GERRIT_BRANCH"
992           submodule-recursive: "{submodule-recursive}"
993           submodule-timeout: "{submodule-timeout}"
994           submodule-disable: "{submodule-disable}"
995           # merge jobs always build from tip
996           choosing-strategy: default
997
998     triggers:
999       - timed: "{obj:cron}"
1000       - gerrit:
1001           server-name: "{gerrit-server-name}"
1002           trigger-on:
1003             - change-merged-event
1004             - comment-added-contains-event:
1005                 comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
1006           projects:
1007             - project-compare-type: ANT
1008               project-pattern: "{project}"
1009               branches:
1010                 - branch-compare-type: ANT
1011                   branch-pattern: "**/{branch}"
1012               file-paths: "{obj:gerrit_trigger_file_paths}"
1013
1014 - job-template:
1015     name: "{project-name}-pypi-merge-{stream}"
1016     id: github-pypi-merge
1017     <<: *lf_pypi_common
1018     <<: *lf_pypi_merge_builders
1019
1020     cron: ""
1021     pypi-repo: pypi-test
1022
1023     properties:
1024       - github:
1025           url: "{github-url}/{github-org}/{project}"
1026
1027     scm:
1028       - lf-infra-github-scm:
1029           url: "{git-clone-url}{github-org}/{project}"
1030           refspec: ""
1031           branch: "refs/heads/{branch}"
1032           submodule-recursive: "{submodule-recursive}"
1033           submodule-timeout: "{submodule-timeout}"
1034           submodule-disable: "{submodule-disable}"
1035           choosing-strategy: default
1036           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1037
1038     triggers:
1039       - timed: "{obj:cron}"
1040       - github-pull-request:
1041           trigger-phrase: "^remerge$"
1042           only-trigger-phrase: false
1043           status-context: "Merge"
1044           permit-all: true
1045           github-hooks: true
1046           org-list:
1047             - "{github-org}"
1048           white-list: "{obj:github_pr_whitelist}"
1049           admin-list: "{obj:github_pr_admin_list}"
1050           white-list-target-branches:
1051             - "{branch}"
1052           included-regions: "{obj:github_included_regions}"