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