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