5d62828a821d31b0305bfc55e19849daca014621
[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-qualitygate-wait: false
259     # SonarCloud scan using jdk8 will become deprecated by Oct, 2020
260     # Projects not compatible with jdk11 can set java-version to something else
261     sonarcloud-java-version: openjdk11
262     stream: master
263     submodule-recursive: true
264     submodule-timeout: 10
265     submodule-disable: false
266     tox-dir: "."
267     tox-envs: ""
268     scan-dev-branch: false
269
270     gerrit_trigger_file_paths:
271       - compare-type: REG_EXP
272         pattern: ".*"
273
274     # github_included_regions MUST match gerrit_trigger_file_paths
275     github_included_regions:
276       - ".*"
277
278     #####################
279     # Job Configuration #
280     #####################
281
282     disabled: "{disable-job}"
283
284     parameters:
285       - lf-infra-parameters:
286           project: "{project}"
287           branch: "{branch}"
288           stream: "{stream}"
289       - lf-infra-maven-parameters:
290           mvn-opts: "{mvn-opts}"
291           mvn-params: "{mvn-params}"
292           mvn-version: "{mvn-version}"
293       - lf-infra-tox-parameters:
294           tox-dir: "{tox-dir}"
295           tox-envs: "{tox-envs}"
296       - string:
297           name: ARCHIVE_ARTIFACTS
298           default: "{archive-artifacts}"
299           description: Artifacts to archive to the logs server.
300       - string:
301           name: MVN
302           # Sets an env var for shell scripts to be able to call the dynamically
303           # installed maven without having to calculate the path themselves.
304           # yamllint disable-line rule:line-length
305           default: "/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn"
306           description: "Maven selector to be used by shell scripts"
307       - string:
308           name: SONAR_MAVEN_GOAL
309           default: "{sonar-mvn-goal}"
310           description: |
311             Maven goals to pass to the Sonar call. Typically sonar:sonar
312             however to use a specific version of the sonar-maven-plugin we
313             can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
314
315     builders:
316       - lf-infra-pre-build
317       - lf-infra-tox-install:
318           python-version: "{python-version}"
319       - shell: "{pre-build-script}"
320       - lf-infra-tox-run:
321           parallel: "{parallel}"
322       - lf-provide-maven-settings:
323           global-settings-file: "{mvn-global-settings}"
324           settings-file: "{mvn-settings}"
325       # With SonarCloud
326       - conditional-step:
327           condition-kind: boolean-expression
328           condition-expression: "{sonarcloud}"
329           steps:
330             - shell: echo 'Using SonarCloud'
331             - lf-infra-maven-sonarcloud:
332                 java-version: "{java-version}"
333                 mvn-goals: "{mvn-goals}"
334                 mvn-settings: "{mvn-settings}"
335                 mvn-version: "{mvn-version}"
336                 sonarcloud-project-key: "{sonarcloud-project-key}"
337                 # yamllint disable-line rule:line-length
338                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
339                 sonarcloud-api-token: "{sonarcloud-api-token}"
340                 sonarcloud-java-version: "{sonarcloud-java-version}"
341                 sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
342                 scan-dev-branch: "{scan-dev-branch}"
343       # With SonarQube
344       - conditional-step:
345           condition-kind: not
346           condition-operand:
347             condition-kind: boolean-expression
348             condition-expression: "{sonarcloud}"
349           steps:
350             - shell: echo 'Using SonarQube'
351             - lf-infra-maven-sonar:
352                 java-version: "{java-version}"
353                 mvn-goals: "{mvn-goals}"
354                 mvn-settings: "{mvn-settings}"
355                 mvn-version: "{mvn-version}"
356
357     publishers:
358       - lf-infra-publish
359
360 - job-template:
361     name: "{project-name}-tox-sonar"
362     id: gerrit-tox-sonar
363     <<: *lf_python_common
364     <<: *lf_tox_sonar
365
366     ######################
367     # Default parameters #
368     ######################
369
370     gerrit_sonar_triggers:
371       - comment-added-contains-event:
372           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
373
374     #####################
375     # Job Configuration #
376     #####################
377
378     scm:
379       - lf-infra-gerrit-scm:
380           jenkins-ssh-credential: "{jenkins-ssh-credential}"
381           git-url: "{git-url}"
382           refspec: $GERRIT_REFSPEC
383           branch: $GERRIT_BRANCH
384           submodule-recursive: "{submodule-recursive}"
385           submodule-timeout: "{submodule-timeout}"
386           submodule-disable: "{submodule-disable}"
387           choosing-strategy: default
388
389     triggers:
390       - timed: "{obj:cron}"
391       - gerrit:
392           server-name: "{gerrit-server-name}"
393           trigger-on: "{obj:gerrit_sonar_triggers}"
394           projects:
395             - project-compare-type: "ANT"
396               project-pattern: "{project}"
397               branches:
398                 - branch-compare-type: "ANT"
399                   branch-pattern: "**/{branch}"
400               file-paths: "{obj:gerrit_trigger_file_paths}"
401           skip-vote:
402             successful: true
403             failed: true
404             unstable: true
405             notbuilt: true
406
407 - job-template:
408     name: "{project-name}-tox-sonar"
409     id: github-tox-sonar
410     <<: *lf_python_common
411     <<: *lf_tox_sonar
412
413     properties:
414       - lf-infra-properties:
415           build-days-to-keep: "{build-days-to-keep}"
416       - github:
417           url: "{github-url}/{github-org}/{project}"
418
419     scm:
420       - lf-infra-github-scm:
421           url: "{git-clone-url}{github-org}/{project}"
422           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
423           branch: "$sha1"
424           submodule-recursive: "{submodule-recursive}"
425           submodule-timeout: "{submodule-timeout}"
426           submodule-disable: "{submodule-disable}"
427           choosing-strategy: default
428           jenkins-ssh-credential: "{jenkins-ssh-credential}"
429
430     triggers:
431       - github-pull-request:
432           trigger-phrase: "^run-sonar$"
433           only-trigger-phrase: false
434           status-context: "Python Sonar"
435           permit-all: true
436           github-hooks: true
437           white-list-target-branches:
438             - "{branch}"
439           included-regions: "{obj:github_included_regions}"
440
441 #################
442 # Tox SonarQube #
443 #################
444
445 - lf_tox_sonarqube: &lf_tox_sonarqube
446     name: lf-tox-sonarqube
447
448     ######################
449     # Default parameters #
450     ######################
451
452     archive-artifacts: >
453       **/*.log
454     branch: master # Sonar should always be run on master branch
455     build-days-to-keep: 7
456     build-timeout: 15
457     cron: "@weekly"
458     disable-job: false
459     git-url: "$GIT_URL/$PROJECT"
460     github-url: "https://github.com"
461     parallel: false
462     pre-build-script: "# pre-build script goes here"
463     python-version: python3
464     stream: master
465     submodule-recursive: true
466     submodule-timeout: 10
467     submodule-disable: false
468     tox-dir: "."
469     tox-envs: ""
470     # Sonar properties
471     sonar-additional-args: ""
472     sonar-java-opts: ""
473     sonar-project-file: "sonar-project.properties"
474     sonar-properties: ""
475     sonar-task: ""
476
477     #####################
478     # Job Configuration #
479     #####################
480
481     project-type: freestyle
482     node: "{build-node}"
483     disabled: "{disable-job}"
484
485     properties:
486       - lf-infra-properties:
487           build-days-to-keep: "{build-days-to-keep}"
488
489     wrappers:
490       - lf-infra-wrappers:
491           build-timeout: "{build-timeout}"
492           jenkins-ssh-credential: "{jenkins-ssh-credential}"
493
494     parameters:
495       - lf-infra-parameters:
496           project: "{project}"
497           branch: "{branch}"
498           stream: "{stream}"
499       - lf-infra-tox-parameters:
500           tox-dir: "{tox-dir}"
501           tox-envs: "{tox-envs}"
502       - string:
503           name: ARCHIVE_ARTIFACTS
504           default: "{archive-artifacts}"
505           description: Artifacts to archive to the logs server.
506
507     builders:
508       - lf-infra-pre-build
509       - lf-infra-tox-install:
510           python-version: "{python-version}"
511       - shell: "{pre-build-script}"
512       - lf-infra-tox-run:
513           parallel: "{parallel}"
514       - lf-infra-sonar:
515           sonar-task: "{sonar-task}"
516           sonar-project-file: "{sonar-project-file}"
517           sonar-properties: "{sonar-properties}"
518           sonar-java-opts: "{sonar-java-opts}"
519           sonar-additional-args: "{sonar-additional-args}"
520
521     publishers:
522       - lf-infra-publish
523
524 - job-template:
525     name: "{project-name}-tox-sonarqube"
526     id: gerrit-tox-sonarqube
527     concurrent: false
528     <<: *lf_tox_sonarqube
529
530     ######################
531     # Default parameters #
532     ######################
533
534     gerrit_sonar_triggers:
535       - comment-added-contains-event:
536           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
537
538     scm:
539       - lf-infra-gerrit-scm:
540           branch: "$GERRIT_BRANCH"
541           jenkins-ssh-credential: "{jenkins-ssh-credential}"
542           git-url: "{git-url}"
543           refspec: "$GERRIT_REFSPEC"
544           submodule-recursive: "{submodule-recursive}"
545           submodule-timeout: "{submodule-timeout}"
546           submodule-disable: "{submodule-disable}"
547           choosing-strategy: default
548
549     triggers:
550       - timed: "{obj:cron}"
551       - gerrit:
552           server-name: "{gerrit-server-name}"
553           trigger-on: "{obj:gerrit_sonar_triggers}"
554           projects:
555             - project-compare-type: "ANT"
556               project-pattern: "{project}"
557               branches:
558                 - branch-compare-type: "ANT"
559                   branch-pattern: "**/{branch}"
560
561 - job-template:
562     name: "{project-name}-tox-sonarqube"
563     id: github-tox-sonarqube
564     concurrent: false
565     <<: *lf_tox_sonarqube
566
567     scm:
568       - lf-infra-github-scm:
569           branch: "$sha1"
570           jenkins-ssh-credential: "{jenkins-ssh-credential}"
571           url: "{git-clone-url}{github-org}/{project}"
572           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
573           submodule-recursive: "{submodule-recursive}"
574           submodule-timeout: "{submodule-timeout}"
575           submodule-disable: "{submodule-disable}"
576           choosing-strategy: default
577
578     triggers:
579       - github-pull-request:
580           trigger-phrase: "^run-sonar$"
581           only-trigger-phrase: false
582           status-context: "Tox Sonarqube"
583           permit-all: true
584           github-hooks: true
585           white-list-target-branches:
586             - "{branch}"
587
588 ##############
589 # Tox Common #
590 ##############
591
592 - lf_tox_common: &lf_tox_common
593     name: lf-tox-common
594
595     ######################
596     # Default parameters #
597     ######################
598
599     branch: master
600     build-days-to-keep: 7
601     build-timeout: 15
602     disable-job: false
603     git-url: "$GIT_URL/$GERRIT_PROJECT"
604     github-url: "https://github.com"
605     parallel: false
606     pre-build-script: "# pre-build script goes here"
607     python-version: python3
608     stream: master
609     submodule-recursive: true
610     submodule-timeout: 10
611     submodule-disable: false
612     tox-dir: "."
613     tox-envs: ""
614
615     gerrit_trigger_file_paths:
616       - compare-type: REG_EXP
617         pattern: ".*"
618
619     # github_included_regions MUST match gerrit_trigger_file_paths
620     github_included_regions:
621       - ".*"
622
623     #####################
624     # Job Configuration #
625     #####################
626
627     project-type: freestyle
628     node: "{build-node}"
629     concurrent: true
630     disabled: "{disable-job}"
631
632     properties:
633       - lf-infra-properties:
634           build-days-to-keep: "{build-days-to-keep}"
635
636     parameters:
637       - lf-infra-parameters:
638           project: "{project}"
639           branch: "{branch}"
640           stream: "{stream}"
641       - lf-infra-tox-parameters:
642           tox-dir: "{tox-dir}"
643           tox-envs: "{tox-envs}"
644
645     wrappers:
646       - lf-infra-wrappers:
647           build-timeout: "{build-timeout}"
648           jenkins-ssh-credential: "{jenkins-ssh-credential}"
649
650     builders:
651       - lf-infra-pre-build
652       - lf-infra-tox-install:
653           python-version: "{python-version}"
654       - shell: "{pre-build-script}"
655       - lf-infra-tox-run:
656           parallel: "{parallel}"
657
658     publishers:
659       - lf-infra-publish
660
661 - job-template:
662     # Python projects typically use tox to run testing.
663     name: "{project-name}-tox-verify-{stream}"
664     id: gerrit-tox-verify
665     <<: *lf_tox_common
666
667     ######################
668     # Default parameters #
669     ######################
670
671     gerrit-skip-vote: false
672     gerrit_verify_triggers:
673       - patchset-created-event:
674           exclude-drafts: true
675           exclude-trivial-rebase: false
676           exclude-no-code-change: false
677       - draft-published-event
678       - comment-added-contains-event:
679           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
680
681     #####################
682     # Job Configuration #
683     #####################
684
685     scm:
686       - lf-infra-gerrit-scm:
687           jenkins-ssh-credential: "{jenkins-ssh-credential}"
688           git-url: "{git-url}"
689           refspec: "$GERRIT_REFSPEC"
690           branch: "$GERRIT_BRANCH"
691           submodule-recursive: "{submodule-recursive}"
692           submodule-timeout: "{submodule-timeout}"
693           submodule-disable: "{submodule-disable}"
694           choosing-strategy: gerrit
695
696     triggers:
697       - gerrit:
698           server-name: "{gerrit-server-name}"
699           trigger-on: "{obj:gerrit_verify_triggers}"
700           projects:
701             - project-compare-type: ANT
702               project-pattern: "{project}"
703               branches:
704                 - branch-compare-type: ANT
705                   branch-pattern: "**/{branch}"
706               file-paths: "{obj:gerrit_trigger_file_paths}"
707           skip-vote:
708             successful: "{gerrit-skip-vote}"
709             failed: "{gerrit-skip-vote}"
710             unstable: "{gerrit-skip-vote}"
711             notbuilt: "{gerrit-skip-vote}"
712
713 - job-template:
714     # Python projects typically use tox to run testing.
715     name: "{project-name}-tox-verify-{stream}"
716     id: github-tox-verify
717     <<: *lf_tox_common
718
719     properties:
720       - lf-infra-properties:
721           build-days-to-keep: "{build-days-to-keep}"
722       - github:
723           url: "{github-url}/{github-org}/{project}"
724
725     scm:
726       - lf-infra-github-scm:
727           url: "{git-clone-url}{github-org}/{project}"
728           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
729           branch: "$sha1"
730           submodule-recursive: "{submodule-recursive}"
731           submodule-timeout: "{submodule-timeout}"
732           submodule-disable: "{submodule-disable}"
733           choosing-strategy: default
734           jenkins-ssh-credential: "{jenkins-ssh-credential}"
735
736     triggers:
737       - github-pull-request:
738           trigger-phrase: "^(recheck|reverify)$"
739           only-trigger-phrase: false
740           status-context: "Tox Verify"
741           permit-all: true
742           github-hooks: true
743           white-list-target-branches:
744             - "{branch}"
745           included-regions: "{obj:github_included_regions}"
746
747 - job-template:
748     # Run tox after merge of gerrit change set
749     name: "{project-name}-tox-merge-{stream}"
750     id: gerrit-tox-merge
751     <<: *lf_tox_common
752
753     ######################
754     # Default parameters #
755     ######################
756
757     gerrit_merge_triggers:
758       - change-merged-event
759       - comment-added-contains-event:
760           comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
761
762     #####################
763     # Job Configuration #
764     #####################
765
766     scm:
767       - lf-infra-gerrit-scm:
768           jenkins-ssh-credential: "{jenkins-ssh-credential}"
769           git-url: "{git-url}"
770           refspec: "$GERRIT_REFSPEC"
771           branch: "$GERRIT_BRANCH"
772           submodule-recursive: "{submodule-recursive}"
773           submodule-timeout: "{submodule-timeout}"
774           submodule-disable: "{submodule-disable}"
775           # merge jobs always build from tip
776           choosing-strategy: default
777
778     triggers:
779       - gerrit:
780           server-name: "{gerrit-server-name}"
781           trigger-on: "{obj:gerrit_merge_triggers}"
782           projects:
783             - project-compare-type: ANT
784               project-pattern: "{project}"
785               branches:
786                 - branch-compare-type: ANT
787                   branch-pattern: "**/{branch}"
788               file-paths: "{obj:gerrit_trigger_file_paths}"
789
790 - job-template:
791     # Run tox after merge of github pull request
792     name: "{project-name}-tox-merge-{stream}"
793     id: github-tox-merge
794     <<: *lf_tox_common
795
796     properties:
797       - lf-infra-properties:
798           build-days-to-keep: "{build-days-to-keep}"
799       - github:
800           url: "{github-url}/{github-org}/{project}"
801
802     scm:
803       - lf-infra-github-scm:
804           url: "{git-clone-url}{github-org}/{project}"
805           refspec: ""
806           branch: "refs/heads/{branch}"
807           submodule-recursive: "{submodule-recursive}"
808           submodule-timeout: "{submodule-timeout}"
809           submodule-disable: "{submodule-disable}"
810           choosing-strategy: default
811           jenkins-ssh-credential: "{jenkins-ssh-credential}"
812
813     triggers:
814       - github-pull-request:
815           trigger-phrase: "^remerge$"
816           only-trigger-phrase: true
817           status-context: "Tox Merge"
818           permit-all: true
819           github-hooks: true
820           org-list:
821             - "{github-org}"
822           white-list: "{obj:github_pr_allowlist}"
823           admin-list: "{obj:github_pr_admin_list}"
824           white-list-target-branches:
825             - "{branch}"
826           included-regions: "{obj:github_included_regions}"
827
828 ########
829 # PyPI #
830 ########
831
832 - lf_pypi_common: &lf_pypi_common
833     name: lf-pypi-common
834
835     ######################
836     # Default parameters #
837     ######################
838
839     archive-artifacts: >
840       **/*.log
841     branch: master
842     build-days-to-keep: 7
843     build-timeout: 15
844     disable-job: false
845     dist-binary: true
846     git-url: "$GIT_URL/$GERRIT_PROJECT"
847     github-url: "https://github.com"
848     parallel: false
849     pre-build-script: "# pre-build script goes here"
850     python-version: python3
851     stream: master
852     submodule-disable: false
853     submodule-recursive: true
854     submodule-timeout: 10
855     tox-dir: "."
856     tox-envs: ""
857
858     gerrit_trigger_file_paths:
859       - compare-type: REG_EXP
860         pattern: ".*"
861
862     # github_included_regions MUST match gerrit_trigger_file_paths
863     github_included_regions:
864       - ".*"
865
866     #####################
867     # Job Configuration #
868     #####################
869
870     project-type: freestyle
871     node: "{build-node}"
872     disabled: "{disable-job}"
873
874     properties:
875       - lf-infra-properties:
876           build-days-to-keep: "{build-days-to-keep}"
877
878     parameters:
879       - lf-infra-parameters:
880           project: "{project}"
881           branch: "{branch}"
882           stream: "{stream}"
883       - lf-infra-tox-parameters:
884           tox-dir: "{tox-dir}"
885           tox-envs: "{tox-envs}"
886       - bool:
887           name: BUILD_BDIST_WHEEL
888           default: "{dist-binary}"
889           description: "Set to True (checked) to build a binary distribution"
890       - bool:
891           name: DRY_RUN
892           default: false
893           description: "Set to True (checked) to skip uploading artifacts"
894
895     wrappers:
896       - lf-infra-wrappers:
897           build-timeout: "{build-timeout}"
898           jenkins-ssh-credential: "{jenkins-ssh-credential}"
899
900     publishers:
901       - lf-infra-publish
902
903 - lf_pypi_verify_builders: &lf_pypi_verify_builders
904     name: lf-pypi-verify-builders
905
906     builders:
907       - lf-infra-pre-build
908       - lf-infra-tox-install:
909           python-version: "{python-version}"
910       - shell: "{pre-build-script}"
911       - lf-infra-tox-run:
912           parallel: "{parallel}"
913       - shell: !include-raw-escape: ../shell/pypi-dist-build.sh
914
915 - lf_pypi_publish_builders: &lf_pypi_publish_builders
916     name: lf-pypi-publish-builders
917
918     builders:
919       - lf-infra-pre-build
920       - lf-infra-tox-install:
921           python-version: "{python-version}"
922       - shell: "{pre-build-script}"
923       - lf-infra-tox-run:
924           parallel: "{parallel}"
925       - shell: !include-raw-escape: ../shell/pypi-dist-build.sh
926       - config-file-provider:
927           files:
928             - file-id: pypirc
929               target: "$HOME/.pypirc"
930       - inject:
931           properties-content: "REPOSITORY={pypi-repo}"
932       - shell: !include-raw-escape: ../shell/pypi-upload.sh
933
934 - job-template:
935     name: "{project-name}-pypi-verify-{stream}"
936     id: gerrit-pypi-verify
937     <<: *lf_pypi_common
938     <<: *lf_pypi_verify_builders
939
940     scm:
941       - lf-infra-gerrit-scm:
942           jenkins-ssh-credential: "{jenkins-ssh-credential}"
943           git-url: "{git-url}"
944           refspec: "$GERRIT_REFSPEC"
945           branch: "$GERRIT_BRANCH"
946           submodule-recursive: "{submodule-recursive}"
947           submodule-timeout: "{submodule-timeout}"
948           submodule-disable: "{submodule-disable}"
949           choosing-strategy: gerrit
950
951     triggers:
952       - gerrit:
953           server-name: "{gerrit-server-name}"
954           trigger-on:
955             - patchset-created-event:
956                 exclude-drafts: true
957                 exclude-trivial-rebase: false
958                 exclude-no-code-change: false
959             - draft-published-event
960             - comment-added-contains-event:
961                 # yamllint disable-line rule:line-length
962                 comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
963           projects:
964             - project-compare-type: ANT
965               project-pattern: "{project}"
966               branches:
967                 - branch-compare-type: ANT
968                   branch-pattern: "**/{branch}"
969               file-paths: "{obj:gerrit_trigger_file_paths}"
970
971 - job-template:
972     name: "{project-name}-pypi-verify-{stream}"
973     id: github-pypi-verify
974     <<: *lf_pypi_common
975     <<: *lf_pypi_verify_builders
976
977     properties:
978       - github:
979           url: "{github-url}/{github-org}/{project}"
980
981     scm:
982       - lf-infra-github-scm:
983           url: "{git-clone-url}{github-org}/{project}"
984           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
985           branch: "$sha1"
986           submodule-recursive: "{submodule-recursive}"
987           submodule-timeout: "{submodule-timeout}"
988           submodule-disable: "{submodule-disable}"
989           choosing-strategy: default
990           jenkins-ssh-credential: "{jenkins-ssh-credential}"
991
992     triggers:
993       - github-pull-request:
994           trigger-phrase: "^(recheck|reverify)$"
995           only-trigger-phrase: false
996           status-context: "PyPI Verify"
997           permit-all: true
998           github-hooks: true
999           white-list-target-branches:
1000             - "{branch}"
1001           included-regions: "{obj:github_included_regions}"
1002
1003 - job-template:
1004     name: "{project-name}-pypi-merge-{stream}"
1005     id: gerrit-pypi-merge
1006     <<: *lf_pypi_common
1007     <<: *lf_pypi_publish_builders
1008
1009     cron: "" # avoid for pypi which rejects duplicates
1010     pypi-repo: pypi-test
1011
1012     scm:
1013       - lf-infra-gerrit-scm:
1014           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1015           git-url: "{git-url}"
1016           refspec: "$GERRIT_REFSPEC"
1017           branch: "$GERRIT_BRANCH"
1018           submodule-recursive: "{submodule-recursive}"
1019           submodule-timeout: "{submodule-timeout}"
1020           submodule-disable: "{submodule-disable}"
1021           # merge jobs always build from tip
1022           choosing-strategy: default
1023
1024     triggers:
1025       - timed: "{obj:cron}"
1026       - gerrit:
1027           server-name: "{gerrit-server-name}"
1028           trigger-on:
1029             - change-merged-event
1030             - comment-added-contains-event:
1031                 comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
1032           projects:
1033             - project-compare-type: ANT
1034               project-pattern: "{project}"
1035               branches:
1036                 - branch-compare-type: ANT
1037                   branch-pattern: "**/{branch}"
1038               file-paths: "{obj:gerrit_trigger_file_paths}"
1039
1040 - job-template:
1041     name: "{project-name}-pypi-merge-{stream}"
1042     id: github-pypi-merge
1043     <<: *lf_pypi_common
1044     <<: *lf_pypi_publish_builders
1045
1046     cron: ""
1047     pypi-repo: pypi-test
1048
1049     properties:
1050       - github:
1051           url: "{github-url}/{github-org}/{project}"
1052
1053     scm:
1054       - lf-infra-github-scm:
1055           url: "{git-clone-url}{github-org}/{project}"
1056           refspec: ""
1057           branch: "refs/heads/{branch}"
1058           submodule-recursive: "{submodule-recursive}"
1059           submodule-timeout: "{submodule-timeout}"
1060           submodule-disable: "{submodule-disable}"
1061           choosing-strategy: default
1062           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1063
1064     triggers:
1065       - timed: "{obj:cron}"
1066       - github-pull-request:
1067           trigger-phrase: "^remerge$"
1068           only-trigger-phrase: false
1069           status-context: "Merge"
1070           permit-all: true
1071           github-hooks: true
1072           org-list:
1073             - "{github-org}"
1074           white-list: "{obj:github_pr_allowlist}"
1075           admin-list: "{obj:github_pr_admin_list}"
1076           white-list-target-branches:
1077             - "{branch}"
1078           included-regions: "{obj:github_included_regions}"
1079
1080 - job-template:
1081     name: "{project-name}-pypi-stage-{stream}"
1082     id: gerrit-pypi-stage
1083     <<: *lf_pypi_common
1084     <<: *lf_pypi_publish_builders
1085
1086     cron: ""
1087     pypi-repo: pypi-test
1088
1089     gerrit_stage_triggers:
1090       - comment-added-contains-event:
1091           comment-contains-value: '^Patch Set\s+\d+:\s+stage-release\s*$'
1092
1093     scm:
1094       - lf-infra-gerrit-scm:
1095           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1096           git-url: "{git-url}"
1097           refspec: "$GERRIT_REFSPEC"
1098           branch: "$GERRIT_BRANCH"
1099           submodule-recursive: "{submodule-recursive}"
1100           submodule-timeout: "{submodule-timeout}"
1101           submodule-disable: "{submodule-disable}"
1102           # stage jobs always build from tip
1103           choosing-strategy: default
1104
1105     triggers:
1106       - timed: "{obj:cron}"
1107       - gerrit:
1108           server-name: "{gerrit-server-name}"
1109           trigger-on: "{obj:gerrit_stage_triggers}"
1110           projects:
1111             - project-compare-type: ANT
1112               project-pattern: "{project}"
1113               branches:
1114                 - branch-compare-type: ANT
1115                   branch-pattern: "**/{branch}"
1116               file-paths: "{obj:gerrit_trigger_file_paths}"
1117
1118 - job-template:
1119     name: "{project-name}-pypi-stage-{stream}"
1120     id: github-pypi-stage
1121     <<: *lf_pypi_common
1122     <<: *lf_pypi_publish_builders
1123
1124     cron: ""
1125     pypi-repo: pypi-test
1126
1127     properties:
1128       - github:
1129           url: "{github-url}/{github-org}/{project}"
1130
1131     scm:
1132       - lf-infra-github-scm:
1133           url: "{git-clone-url}{github-org}/{project}"
1134           refspec: ""
1135           branch: "refs/heads/{branch}"
1136           submodule-recursive: "{submodule-recursive}"
1137           submodule-timeout: "{submodule-timeout}"
1138           submodule-disable: "{submodule-disable}"
1139           choosing-strategy: default
1140           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1141
1142     triggers:
1143       - timed: "{obj:cron}"
1144       - github-pull-request:
1145           trigger-phrase: "^stage-release$"
1146           only-trigger-phrase: true
1147           status-context: "Release"
1148           permit-all: true
1149           github-hooks: true
1150           white-list-target-branches:
1151             - "{branch}"
1152           included-regions: "{obj:github_included_regions}"