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