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