bb123f4718261b6bebdfc4b6ba678a10f4a902b8
[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 Snyk CLI #
232 ###################
233
234 - lf_python_snyk_cli: &lf_python_snyk_cli
235     name: lf-python-snyk_cli
236
237     ######################
238     # Default parameters #
239     ######################
240
241     branch: master
242     build-days-to-keep: 30 # 30 days for troubleshooting purposes
243     build-timeout: 60
244     disable-job: false
245     git-url: "$GIT_URL/$PROJECT"
246     github-url: "https://github.com"
247     java-version: openjdk11
248     parallel: false
249     pre-build-script: "# pre-build script goes here"
250     python-version: python3
251     snyk-cli-options: ""
252     snyk-token-credential-id: snyk-token
253     snyk-org-credential-id: snyk-org
254     stream: master
255     submodule-recursive: true
256     submodule-timeout: 10
257     submodule-disable: false
258     tox-dir: "."
259     tox-envs: ""
260
261     gerrit_snyk_triggers:
262       - comment-added-contains-event:
263           comment-contains-value: '^Patch Set\s+\d+:\s+run-snyk\s*$'
264
265     parameters:
266       - lf-infra-parameters:
267           project: "{project}"
268           branch: "{branch}"
269           stream: "{stream}"
270       - string:
271           name: SNYK_CLI_OPTIONS
272           default: "{snyk-cli-options}"
273           description: Additional Snyk CLI commands and options
274       - lf-infra-tox-parameters:
275           tox-dir: "{tox-dir}"
276           tox-envs: "{tox-envs}"
277
278     wrappers:
279       - credentials-binding:
280           - text:
281               credential-id: "{snyk-token-credential-id}"
282               variable: SNYK_TOKEN
283           - text:
284               credential-id: "{snyk-org-credential-id}"
285               variable: SNYK_ORG
286
287     #####################
288     # Job Configuration #
289     #####################
290
291     disabled: "{disable-job}"
292
293     builders:
294       - lf-infra-pre-build
295       - lf-infra-tox-install:
296           python-version: "{python-version}"
297       - shell: "{pre-build-script}"
298       - lf-infra-tox-run:
299           parallel: "{parallel}"
300       - lf-infra-snyk-cli-scanner
301
302 - job-template:
303     name: "{project-name}-python-snyk-cli-{stream}"
304     id: gerrit-python-snyk-cli
305     # yamllint disable-line rule:key-duplicates
306     <<: *lf_python_snyk_cli
307
308     scm:
309       - lf-infra-gerrit-scm:
310           jenkins-ssh-credential: "{jenkins-ssh-credential}"
311           git-url: "{git-url}"
312           refspec: "$GERRIT_REFSPEC"
313           branch: "$GERRIT_BRANCH"
314           submodule-recursive: "{submodule-recursive}"
315           submodule-timeout: "{submodule-timeout}"
316           submodule-disable: "{submodule-disable}"
317           choosing-strategy: default
318
319     triggers:
320       # Build weekly on Saturdays
321       - timed: "H H * * 6"
322       - gerrit:
323           server-name: "{gerrit-server-name}"
324           trigger-on: "{obj:gerrit_snyk_triggers}"
325           projects:
326             - project-compare-type: ANT
327               project-pattern: "{project}"
328               branches:
329                 - branch-compare-type: ANT
330                   branch-pattern: "**/{branch}"
331           skip-vote:
332             successful: true
333             failed: true
334             unstable: true
335             notbuilt: true
336
337 - job-template:
338     name: "{project-name}-python-snyk-cli-{stream}"
339     id: github-python-snyk-cli
340     # yamllint disable-line rule:key-duplicates
341     <<: *lf_python_snyk_cli
342
343     properties:
344       - lf-infra-properties:
345           build-days-to-keep: "{build-days-to-keep}"
346       - github:
347           url: "{github-url}/{github-org}/{project}"
348
349     scm:
350       - lf-infra-github-scm:
351           url: "{git-clone-url}{github-org}/{project}"
352           refspec: ""
353           branch: "refs/heads/{branch}"
354           submodule-recursive: "{submodule-recursive}"
355           submodule-timeout: "{submodule-timeout}"
356           submodule-disable: "{submodule-disable}"
357           choosing-strategy: default
358           jenkins-ssh-credential: "{jenkins-ssh-credential}"
359
360     triggers:
361       # Build weekly on Saturdays
362       - timed: "H H * * 6"
363       - github-pull-request:
364           trigger-phrase: "^run-snyk$"
365           only-trigger-phrase: true
366           status-context: "SNYK scan"
367           permit-all: true
368           github-hooks: true
369           org-list:
370             - "{github-org}"
371           white-list: "{obj:github_pr_allowlist}"
372           admin-list: "{obj:github_pr_admin_list}"
373           white-list-target-branches:
374             - "{branch}"
375
376 #########################
377 # Python Sonar with CLI #
378 #########################
379
380 - lf_cli_sonar: &lf_cli_sonar
381     name: lf-cli-sonar
382
383     ######################
384     # Default parameters #
385     ######################
386
387     branch: master # Sonar should always be run on master branch
388     build-days-to-keep: 7
389     build-timeout: 60
390     cron: "H H * * *" # run daily
391     disable-job: false
392     git-url: "$GIT_URL/$PROJECT"
393     github-url: "https://github.com"
394     # SonarCloud scan using jdk8 will become deprecated by Oct, 2020
395     # Projects not compatible with jdk11 can set java-version to something else
396     java-version: openjdk11
397     parallel: true
398     pre-build-script: "# pre-build script goes here"
399     python-version: python3
400     stream: master
401     sonar-scanner-version: "4.7.0.2747"
402     sonar-scanner-home: "$WORKSPACE/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux"
403     sonar-scanner-opts: "-server"
404     submodule-recursive: true
405     submodule-timeout: 10
406     submodule-disable: false
407     tox-dir: "."
408     tox-envs: ""
409
410     gerrit_trigger_file_paths:
411       - compare-type: REG_EXP
412         pattern: ".*"
413
414     # github_included_regions MUST match gerrit_trigger_file_paths
415     github_included_regions:
416       - ".*"
417
418     #####################
419     # Job Configuration #
420     #####################
421
422     disabled: "{disable-job}"
423
424     parameters:
425       - lf-infra-parameters:
426           project: "{project}"
427           branch: "{branch}"
428           stream: "{stream}"
429       - lf-infra-sonar-cli-parameters:
430           tox-dir: "{tox-dir}"
431           tox-envs: "{tox-envs}"
432           sonar-scanner-version: "{sonar-scanner-version}"
433           sonar-scanner-home: "{sonar-scanner-home}"
434           sonar-scanner-opts: "{sonar-scanner-opts}"
435       - string:
436           name: ARCHIVE_ARTIFACTS
437           default: "{archive-artifacts}"
438           description: Artifacts to archive to the logs server.
439     wrappers:
440       - credentials-binding:
441           - text:
442               credential-id: sonar-token-{project-name}
443               variable: SONAR_TOKEN
444     builders:
445       - lf-infra-pre-build
446       - lf-infra-tox-install:
447           python-version: "{python-version}"
448       - shell: "{pre-build-script}"
449       - lf-infra-tox-run:
450           parallel: "{parallel}"
451       # With Sonar CLI
452       - inject:
453           properties-content: |
454             SONARCLOUD_PROJECT_ORGANIZATION={sonarcloud-project-organization}
455             SONARCLOUD_PROJECT_KEY={sonarcloud-project-key}
456       - shell: !include-raw-escape: ../shell/sonar-cli.sh
457
458     publishers:
459       - lf-infra-publish
460
461 - job-template:
462     name: "{project-name}-cli-sonar"
463     id: gerrit-cli-sonar
464     <<: *lf_python_common
465     <<: *lf_cli_sonar
466
467     ######################
468     # Default parameters #
469     ######################
470
471     gerrit_sonar_triggers:
472       - comment-added-contains-event:
473           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
474
475     #####################
476     # Job Configuration #
477     #####################
478
479     scm:
480       - lf-infra-gerrit-scm:
481           jenkins-ssh-credential: "{jenkins-ssh-credential}"
482           git-url: "{git-url}"
483           refspec: $GERRIT_REFSPEC
484           branch: $GERRIT_BRANCH
485           submodule-recursive: "{submodule-recursive}"
486           submodule-timeout: "{submodule-timeout}"
487           submodule-disable: "{submodule-disable}"
488           choosing-strategy: default
489
490     triggers:
491       - timed: "{obj:cron}"
492       - gerrit:
493           server-name: "{gerrit-server-name}"
494           trigger-on: "{obj:gerrit_sonar_triggers}"
495           projects:
496             - project-compare-type: "ANT"
497               project-pattern: "{project}"
498               branches:
499                 - branch-compare-type: "ANT"
500                   branch-pattern: "**/{branch}"
501               file-paths: "{obj:gerrit_trigger_file_paths}"
502           skip-vote:
503             successful: true
504             failed: true
505             unstable: true
506             notbuilt: true
507
508 - job-template:
509     name: "{project-name}-cli-sonar"
510     id: github-cli-sonar
511     <<: *lf_python_common
512     <<: *lf_cli_sonar
513
514     properties:
515       - lf-infra-properties:
516           build-days-to-keep: "{build-days-to-keep}"
517       - github:
518           url: "{github-url}/{github-org}/{project}"
519
520     scm:
521       - lf-infra-github-scm:
522           url: "{git-clone-url}{github-org}/{project}"
523           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
524           branch: "$sha1"
525           submodule-recursive: "{submodule-recursive}"
526           submodule-timeout: "{submodule-timeout}"
527           submodule-disable: "{submodule-disable}"
528           choosing-strategy: default
529           jenkins-ssh-credential: "{jenkins-ssh-credential}"
530
531     triggers:
532       - github-pull-request:
533           trigger-phrase: "^run-sonar$"
534           only-trigger-phrase: false
535           status-context: "Python Sonar"
536           permit-all: true
537           github-hooks: true
538           white-list-target-branches:
539             - "{branch}"
540           included-regions: "{obj:github_included_regions}"
541
542 #########################
543 # Python Sonar with Tox #
544 #########################
545
546 - lf_tox_sonar: &lf_tox_sonar
547     name: lf-tox-sonar
548
549     ######################
550     # Default parameters #
551     ######################
552
553     branch: master # Sonar should always be run on master branch
554     build-days-to-keep: 7
555     build-timeout: 60
556     cron: "H H * * *" # run daily
557     disable-job: false
558     git-url: "$GIT_URL/$PROJECT"
559     github-url: "https://github.com"
560     java-version: openjdk11
561     mvn-global-settings: global-settings
562     mvn-goals: validate
563     mvn-opts: ""
564     mvn-params: ""
565     mvn-settings: "{mvn-settings}"
566     mvn-version: mvn35
567     parallel: true
568     pre-build-script: "# pre-build script goes here"
569     python-version: python3
570     sonar-mvn-goal: "sonar:sonar"
571     sonarcloud: false
572     sonarcloud-project-key: ""
573     sonarcloud-project-organization: ""
574     sonarcloud-api-token-cred-id: sonarcloud-api-token
575     sonarcloud-qualitygate-wait: false
576     # SonarCloud scan using jdk8 will become deprecated by Oct, 2020
577     # Projects not compatible with jdk11 can set java-version to something else
578     sonarcloud-java-version: openjdk11
579     stream: master
580     submodule-recursive: true
581     submodule-timeout: 10
582     submodule-disable: false
583     tox-dir: "."
584     tox-envs: ""
585     scan-dev-branch: false
586
587     gerrit_trigger_file_paths:
588       - compare-type: REG_EXP
589         pattern: ".*"
590
591     # github_included_regions MUST match gerrit_trigger_file_paths
592     github_included_regions:
593       - ".*"
594
595     #####################
596     # Job Configuration #
597     #####################
598
599     disabled: "{disable-job}"
600
601     parameters:
602       - lf-infra-parameters:
603           project: "{project}"
604           branch: "{branch}"
605           stream: "{stream}"
606       - lf-infra-maven-parameters:
607           mvn-opts: "{mvn-opts}"
608           mvn-params: "{mvn-params}"
609           mvn-version: "{mvn-version}"
610       - lf-infra-tox-parameters:
611           tox-dir: "{tox-dir}"
612           tox-envs: "{tox-envs}"
613       - string:
614           name: ARCHIVE_ARTIFACTS
615           default: "{archive-artifacts}"
616           description: Artifacts to archive to the logs server.
617       - string:
618           name: MVN
619           # Sets an env var for shell scripts to be able to call the dynamically
620           # installed maven without having to calculate the path themselves.
621           # yamllint disable-line rule:line-length
622           default: "/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn"
623           description: "Maven selector to be used by shell scripts"
624       - string:
625           name: SONAR_MAVEN_GOAL
626           default: "{sonar-mvn-goal}"
627           description: |
628             Maven goals to pass to the Sonar call. Typically sonar:sonar
629             however to use a specific version of the sonar-maven-plugin we
630             can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
631
632     wrappers:
633       - credentials-binding:
634           - text:
635               credential-id: "{sonarcloud-api-token-cred-id}"
636               variable: API_TOKEN
637
638     builders:
639       - lf-infra-pre-build
640       - lf-infra-tox-install:
641           python-version: "{python-version}"
642       - shell: "{pre-build-script}"
643       - lf-infra-tox-run:
644           parallel: "{parallel}"
645       - lf-provide-maven-settings:
646           global-settings-file: "{mvn-global-settings}"
647           settings-file: "{mvn-settings}"
648       # With SonarCloud
649       - conditional-step:
650           condition-kind: boolean-expression
651           condition-expression: "{sonarcloud}"
652           steps:
653             - shell: echo 'Using SonarCloud'
654             - lf-infra-maven-sonarcloud:
655                 java-version: "{java-version}"
656                 mvn-goals: "{mvn-goals}"
657                 mvn-settings: "{mvn-settings}"
658                 mvn-version: "{mvn-version}"
659                 sonarcloud-project-key: "{sonarcloud-project-key}"
660                 # yamllint disable-line rule:line-length
661                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
662                 sonarcloud-java-version: "{sonarcloud-java-version}"
663                 sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
664                 scan-dev-branch: "{scan-dev-branch}"
665       # With SonarQube
666       - conditional-step:
667           condition-kind: not
668           condition-operand:
669             condition-kind: boolean-expression
670             condition-expression: "{sonarcloud}"
671           steps:
672             - shell: echo 'Using SonarQube'
673             - lf-infra-maven-sonar:
674                 java-version: "{java-version}"
675                 mvn-goals: "{mvn-goals}"
676                 mvn-settings: "{mvn-settings}"
677                 mvn-version: "{mvn-version}"
678
679     publishers:
680       - lf-infra-publish
681
682 - job-template:
683     name: "{project-name}-tox-sonar"
684     id: gerrit-tox-sonar
685     <<: *lf_python_common
686     <<: *lf_tox_sonar
687
688     ######################
689     # Default parameters #
690     ######################
691
692     gerrit_sonar_triggers:
693       - comment-added-contains-event:
694           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
695
696     #####################
697     # Job Configuration #
698     #####################
699
700     scm:
701       - lf-infra-gerrit-scm:
702           jenkins-ssh-credential: "{jenkins-ssh-credential}"
703           git-url: "{git-url}"
704           refspec: $GERRIT_REFSPEC
705           branch: $GERRIT_BRANCH
706           submodule-recursive: "{submodule-recursive}"
707           submodule-timeout: "{submodule-timeout}"
708           submodule-disable: "{submodule-disable}"
709           choosing-strategy: default
710
711     triggers:
712       - timed: "{obj:cron}"
713       - gerrit:
714           server-name: "{gerrit-server-name}"
715           trigger-on: "{obj:gerrit_sonar_triggers}"
716           projects:
717             - project-compare-type: "ANT"
718               project-pattern: "{project}"
719               branches:
720                 - branch-compare-type: "ANT"
721                   branch-pattern: "**/{branch}"
722               file-paths: "{obj:gerrit_trigger_file_paths}"
723           skip-vote:
724             successful: true
725             failed: true
726             unstable: true
727             notbuilt: true
728
729 - job-template:
730     name: "{project-name}-tox-sonar"
731     id: github-tox-sonar
732     <<: *lf_python_common
733     <<: *lf_tox_sonar
734
735     properties:
736       - lf-infra-properties:
737           build-days-to-keep: "{build-days-to-keep}"
738       - github:
739           url: "{github-url}/{github-org}/{project}"
740
741     scm:
742       - lf-infra-github-scm:
743           url: "{git-clone-url}{github-org}/{project}"
744           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
745           branch: "$sha1"
746           submodule-recursive: "{submodule-recursive}"
747           submodule-timeout: "{submodule-timeout}"
748           submodule-disable: "{submodule-disable}"
749           choosing-strategy: default
750           jenkins-ssh-credential: "{jenkins-ssh-credential}"
751
752     triggers:
753       - github-pull-request:
754           trigger-phrase: "^run-sonar$"
755           only-trigger-phrase: false
756           status-context: "Python Sonar"
757           permit-all: true
758           github-hooks: true
759           white-list-target-branches:
760             - "{branch}"
761           included-regions: "{obj:github_included_regions}"
762
763 #################
764 # Tox SonarQube #
765 #################
766
767 - lf_tox_sonarqube: &lf_tox_sonarqube
768     name: lf-tox-sonarqube
769
770     ######################
771     # Default parameters #
772     ######################
773
774     archive-artifacts: >
775       **/*.log
776     branch: master # Sonar should always be run on master branch
777     build-days-to-keep: 7
778     build-timeout: 15
779     cron: "@weekly"
780     disable-job: false
781     git-url: "$GIT_URL/$PROJECT"
782     github-url: "https://github.com"
783     parallel: false
784     pre-build-script: "# pre-build script goes here"
785     python-version: python3
786     stream: master
787     submodule-recursive: true
788     submodule-timeout: 10
789     submodule-disable: false
790     tox-dir: "."
791     tox-envs: ""
792     # Sonar properties
793     sonar-additional-args: ""
794     sonar-java-opts: ""
795     sonar-project-file: "sonar-project.properties"
796     sonar-properties: ""
797     sonar-task: ""
798
799     #####################
800     # Job Configuration #
801     #####################
802
803     project-type: freestyle
804     node: "{build-node}"
805     disabled: "{disable-job}"
806
807     properties:
808       - lf-infra-properties:
809           build-days-to-keep: "{build-days-to-keep}"
810
811     wrappers:
812       - lf-infra-wrappers:
813           build-timeout: "{build-timeout}"
814           jenkins-ssh-credential: "{jenkins-ssh-credential}"
815
816     parameters:
817       - lf-infra-parameters:
818           project: "{project}"
819           branch: "{branch}"
820           stream: "{stream}"
821       - lf-infra-tox-parameters:
822           tox-dir: "{tox-dir}"
823           tox-envs: "{tox-envs}"
824       - string:
825           name: ARCHIVE_ARTIFACTS
826           default: "{archive-artifacts}"
827           description: Artifacts to archive to the logs server.
828
829     builders:
830       - lf-infra-pre-build
831       - lf-infra-tox-install:
832           python-version: "{python-version}"
833       - shell: "{pre-build-script}"
834       - lf-infra-tox-run:
835           parallel: "{parallel}"
836       - lf-infra-sonar:
837           sonar-task: "{sonar-task}"
838           sonar-project-file: "{sonar-project-file}"
839           sonar-properties: "{sonar-properties}"
840           sonar-java-opts: "{sonar-java-opts}"
841           sonar-additional-args: "{sonar-additional-args}"
842
843     publishers:
844       - lf-infra-publish
845
846 - job-template:
847     name: "{project-name}-tox-sonarqube"
848     id: gerrit-tox-sonarqube
849     concurrent: false
850     <<: *lf_tox_sonarqube
851
852     ######################
853     # Default parameters #
854     ######################
855
856     gerrit_sonar_triggers:
857       - comment-added-contains-event:
858           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
859
860     scm:
861       - lf-infra-gerrit-scm:
862           branch: "$GERRIT_BRANCH"
863           jenkins-ssh-credential: "{jenkins-ssh-credential}"
864           git-url: "{git-url}"
865           refspec: "$GERRIT_REFSPEC"
866           submodule-recursive: "{submodule-recursive}"
867           submodule-timeout: "{submodule-timeout}"
868           submodule-disable: "{submodule-disable}"
869           choosing-strategy: default
870
871     triggers:
872       - timed: "{obj:cron}"
873       - gerrit:
874           server-name: "{gerrit-server-name}"
875           trigger-on: "{obj:gerrit_sonar_triggers}"
876           projects:
877             - project-compare-type: "ANT"
878               project-pattern: "{project}"
879               branches:
880                 - branch-compare-type: "ANT"
881                   branch-pattern: "**/{branch}"
882
883 - job-template:
884     name: "{project-name}-tox-sonarqube"
885     id: github-tox-sonarqube
886     concurrent: false
887     <<: *lf_tox_sonarqube
888
889     scm:
890       - lf-infra-github-scm:
891           branch: "$sha1"
892           jenkins-ssh-credential: "{jenkins-ssh-credential}"
893           url: "{git-clone-url}{github-org}/{project}"
894           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
895           submodule-recursive: "{submodule-recursive}"
896           submodule-timeout: "{submodule-timeout}"
897           submodule-disable: "{submodule-disable}"
898           choosing-strategy: default
899
900     triggers:
901       - github-pull-request:
902           trigger-phrase: "^run-sonar$"
903           only-trigger-phrase: false
904           status-context: "Tox Sonarqube"
905           permit-all: true
906           github-hooks: true
907           white-list-target-branches:
908             - "{branch}"
909
910 ##############
911 # Tox Common #
912 ##############
913
914 - lf_tox_common: &lf_tox_common
915     name: lf-tox-common
916
917     ######################
918     # Default parameters #
919     ######################
920
921     branch: master
922     build-days-to-keep: 7
923     build-timeout: 15
924     disable-job: false
925     git-url: "$GIT_URL/$GERRIT_PROJECT"
926     github-url: "https://github.com"
927     parallel: false
928     pre-build-script: "# pre-build script goes here"
929     python-version: python3
930     stream: master
931     submodule-recursive: true
932     submodule-timeout: 10
933     submodule-disable: false
934     tox-dir: "."
935     tox-envs: ""
936
937     gerrit_trigger_file_paths:
938       - compare-type: REG_EXP
939         pattern: ".*"
940
941     # github_included_regions MUST match gerrit_trigger_file_paths
942     github_included_regions:
943       - ".*"
944
945     #####################
946     # Job Configuration #
947     #####################
948
949     project-type: freestyle
950     node: "{build-node}"
951     concurrent: true
952     disabled: "{disable-job}"
953
954     properties:
955       - lf-infra-properties:
956           build-days-to-keep: "{build-days-to-keep}"
957
958     parameters:
959       - lf-infra-parameters:
960           project: "{project}"
961           branch: "{branch}"
962           stream: "{stream}"
963       - lf-infra-tox-parameters:
964           tox-dir: "{tox-dir}"
965           tox-envs: "{tox-envs}"
966
967     wrappers:
968       - lf-infra-wrappers:
969           build-timeout: "{build-timeout}"
970           jenkins-ssh-credential: "{jenkins-ssh-credential}"
971
972     builders:
973       - lf-infra-pre-build
974       - lf-infra-tox-install:
975           python-version: "{python-version}"
976       - shell: "{pre-build-script}"
977       - lf-infra-tox-run:
978           parallel: "{parallel}"
979
980     publishers:
981       - lf-infra-publish
982
983 - job-template:
984     # Python projects typically use tox to run testing.
985     name: "{project-name}-tox-verify-{stream}"
986     id: gerrit-tox-verify
987     <<: *lf_tox_common
988
989     ######################
990     # Default parameters #
991     ######################
992
993     gerrit-skip-vote: false
994     gerrit_verify_triggers:
995       - patchset-created-event:
996           exclude-drafts: true
997           exclude-trivial-rebase: false
998           exclude-no-code-change: false
999       - draft-published-event
1000       - comment-added-contains-event:
1001           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
1002
1003     #####################
1004     # Job Configuration #
1005     #####################
1006
1007     scm:
1008       - lf-infra-gerrit-scm:
1009           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1010           git-url: "{git-url}"
1011           refspec: "$GERRIT_REFSPEC"
1012           branch: "$GERRIT_BRANCH"
1013           submodule-recursive: "{submodule-recursive}"
1014           submodule-timeout: "{submodule-timeout}"
1015           submodule-disable: "{submodule-disable}"
1016           choosing-strategy: gerrit
1017
1018     triggers:
1019       - gerrit:
1020           server-name: "{gerrit-server-name}"
1021           trigger-on: "{obj:gerrit_verify_triggers}"
1022           projects:
1023             - project-compare-type: ANT
1024               project-pattern: "{project}"
1025               branches:
1026                 - branch-compare-type: ANT
1027                   branch-pattern: "**/{branch}"
1028               file-paths: "{obj:gerrit_trigger_file_paths}"
1029           skip-vote:
1030             successful: "{gerrit-skip-vote}"
1031             failed: "{gerrit-skip-vote}"
1032             unstable: "{gerrit-skip-vote}"
1033             notbuilt: "{gerrit-skip-vote}"
1034
1035 - job-template:
1036     # Python projects typically use tox to run testing.
1037     name: "{project-name}-tox-verify-{stream}"
1038     id: github-tox-verify
1039     <<: *lf_tox_common
1040
1041     properties:
1042       - lf-infra-properties:
1043           build-days-to-keep: "{build-days-to-keep}"
1044       - github:
1045           url: "{github-url}/{github-org}/{project}"
1046
1047     scm:
1048       - lf-infra-github-scm:
1049           url: "{git-clone-url}{github-org}/{project}"
1050           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1051           branch: "$sha1"
1052           submodule-recursive: "{submodule-recursive}"
1053           submodule-timeout: "{submodule-timeout}"
1054           submodule-disable: "{submodule-disable}"
1055           choosing-strategy: default
1056           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1057
1058     triggers:
1059       - github-pull-request:
1060           trigger-phrase: "^(recheck|reverify)$"
1061           only-trigger-phrase: false
1062           status-context: "Tox Verify"
1063           permit-all: true
1064           github-hooks: true
1065           white-list-target-branches:
1066             - "{branch}"
1067           included-regions: "{obj:github_included_regions}"
1068
1069 - job-template:
1070     # Run tox after merge of gerrit change set
1071     name: "{project-name}-tox-merge-{stream}"
1072     id: gerrit-tox-merge
1073     <<: *lf_tox_common
1074
1075     ######################
1076     # Default parameters #
1077     ######################
1078
1079     gerrit_merge_triggers:
1080       - change-merged-event
1081       - comment-added-contains-event:
1082           comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
1083
1084     #####################
1085     # Job Configuration #
1086     #####################
1087
1088     scm:
1089       - lf-infra-gerrit-scm:
1090           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1091           git-url: "{git-url}"
1092           refspec: "$GERRIT_REFSPEC"
1093           branch: "$GERRIT_BRANCH"
1094           submodule-recursive: "{submodule-recursive}"
1095           submodule-timeout: "{submodule-timeout}"
1096           submodule-disable: "{submodule-disable}"
1097           # merge jobs always build from tip
1098           choosing-strategy: default
1099
1100     triggers:
1101       - gerrit:
1102           server-name: "{gerrit-server-name}"
1103           trigger-on: "{obj:gerrit_merge_triggers}"
1104           projects:
1105             - project-compare-type: ANT
1106               project-pattern: "{project}"
1107               branches:
1108                 - branch-compare-type: ANT
1109                   branch-pattern: "**/{branch}"
1110               file-paths: "{obj:gerrit_trigger_file_paths}"
1111
1112 - job-template:
1113     # Run tox after merge of github pull request
1114     name: "{project-name}-tox-merge-{stream}"
1115     id: github-tox-merge
1116     <<: *lf_tox_common
1117
1118     properties:
1119       - lf-infra-properties:
1120           build-days-to-keep: "{build-days-to-keep}"
1121       - github:
1122           url: "{github-url}/{github-org}/{project}"
1123
1124     scm:
1125       - lf-infra-github-scm:
1126           url: "{git-clone-url}{github-org}/{project}"
1127           refspec: ""
1128           branch: "refs/heads/{branch}"
1129           submodule-recursive: "{submodule-recursive}"
1130           submodule-timeout: "{submodule-timeout}"
1131           submodule-disable: "{submodule-disable}"
1132           choosing-strategy: default
1133           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1134
1135     triggers:
1136       - github-pull-request:
1137           trigger-phrase: "^remerge$"
1138           only-trigger-phrase: true
1139           status-context: "Tox Merge"
1140           permit-all: true
1141           github-hooks: true
1142           org-list:
1143             - "{github-org}"
1144           white-list: "{obj:github_pr_allowlist}"
1145           admin-list: "{obj:github_pr_admin_list}"
1146           white-list-target-branches:
1147             - "{branch}"
1148           included-regions: "{obj:github_included_regions}"
1149
1150 ########
1151 # PyPI #
1152 ########
1153
1154 - lf_pypi_common: &lf_pypi_common
1155     name: lf-pypi-common
1156
1157     ######################
1158     # Default parameters #
1159     ######################
1160
1161     archive-artifacts: >
1162       **/*.log
1163     branch: master
1164     build-days-to-keep: 7
1165     build-timeout: 15
1166     disable-job: false
1167     dist-binary: true
1168     git-url: "$GIT_URL/$GERRIT_PROJECT"
1169     github-url: "https://github.com"
1170     parallel: false
1171     pre-build-script: "# pre-build script goes here"
1172     python-version: python3
1173     stream: master
1174     submodule-disable: false
1175     submodule-recursive: true
1176     submodule-timeout: 10
1177     tox-dir: "."
1178     tox-envs: ""
1179
1180     gerrit_trigger_file_paths:
1181       - compare-type: REG_EXP
1182         pattern: ".*"
1183
1184     # github_included_regions MUST match gerrit_trigger_file_paths
1185     github_included_regions:
1186       - ".*"
1187
1188     #####################
1189     # Job Configuration #
1190     #####################
1191
1192     project-type: freestyle
1193     node: "{build-node}"
1194     disabled: "{disable-job}"
1195
1196     properties:
1197       - lf-infra-properties:
1198           build-days-to-keep: "{build-days-to-keep}"
1199
1200     parameters:
1201       - lf-infra-parameters:
1202           project: "{project}"
1203           branch: "{branch}"
1204           stream: "{stream}"
1205       - lf-infra-tox-parameters:
1206           tox-dir: "{tox-dir}"
1207           tox-envs: "{tox-envs}"
1208       - bool:
1209           name: BUILD_BDIST_WHEEL
1210           default: "{dist-binary}"
1211           description: "Set to True (checked) to build a binary distribution"
1212       - bool:
1213           name: DRY_RUN
1214           default: false
1215           description: "Set to True (checked) to skip uploading artifacts"
1216
1217     wrappers:
1218       - lf-infra-wrappers:
1219           build-timeout: "{build-timeout}"
1220           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1221
1222     publishers:
1223       - lf-infra-publish
1224
1225 - lf_pypi_verify_builders: &lf_pypi_verify_builders
1226     name: lf-pypi-verify-builders
1227
1228     builders:
1229       - lf-infra-pre-build
1230       - lf-infra-tox-install:
1231           python-version: "{python-version}"
1232       - shell: "{pre-build-script}"
1233       - lf-infra-tox-run:
1234           parallel: "{parallel}"
1235       - shell: !include-raw-escape: ../shell/pypi-dist-build.sh
1236
1237 - lf_pypi_publish_builders: &lf_pypi_publish_builders
1238     name: lf-pypi-publish-builders
1239
1240     builders:
1241       - lf-infra-pre-build
1242       - lf-infra-tox-install:
1243           python-version: "{python-version}"
1244       - shell: "{pre-build-script}"
1245       - lf-infra-tox-run:
1246           parallel: "{parallel}"
1247       - shell: !include-raw-escape: ../shell/pypi-dist-build.sh
1248       - config-file-provider:
1249           files:
1250             - file-id: pypirc
1251               target: "$HOME/.pypirc"
1252       - inject:
1253           properties-content: "REPOSITORY={pypi-repo}"
1254       - shell: !include-raw-escape: ../shell/pypi-upload.sh
1255
1256 - job-template:
1257     name: "{project-name}-pypi-verify-{stream}"
1258     id: gerrit-pypi-verify
1259     <<: *lf_pypi_common
1260     <<: *lf_pypi_verify_builders
1261
1262     scm:
1263       - lf-infra-gerrit-scm:
1264           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1265           git-url: "{git-url}"
1266           refspec: "$GERRIT_REFSPEC"
1267           branch: "$GERRIT_BRANCH"
1268           submodule-recursive: "{submodule-recursive}"
1269           submodule-timeout: "{submodule-timeout}"
1270           submodule-disable: "{submodule-disable}"
1271           choosing-strategy: gerrit
1272
1273     triggers:
1274       - gerrit:
1275           server-name: "{gerrit-server-name}"
1276           trigger-on:
1277             - patchset-created-event:
1278                 exclude-drafts: true
1279                 exclude-trivial-rebase: false
1280                 exclude-no-code-change: false
1281             - draft-published-event
1282             - comment-added-contains-event:
1283                 # yamllint disable-line rule:line-length
1284                 comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
1285           projects:
1286             - project-compare-type: ANT
1287               project-pattern: "{project}"
1288               branches:
1289                 - branch-compare-type: ANT
1290                   branch-pattern: "**/{branch}"
1291               file-paths: "{obj:gerrit_trigger_file_paths}"
1292
1293 - job-template:
1294     name: "{project-name}-pypi-verify-{stream}"
1295     id: github-pypi-verify
1296     <<: *lf_pypi_common
1297     <<: *lf_pypi_verify_builders
1298
1299     properties:
1300       - github:
1301           url: "{github-url}/{github-org}/{project}"
1302
1303     scm:
1304       - lf-infra-github-scm:
1305           url: "{git-clone-url}{github-org}/{project}"
1306           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1307           branch: "$sha1"
1308           submodule-recursive: "{submodule-recursive}"
1309           submodule-timeout: "{submodule-timeout}"
1310           submodule-disable: "{submodule-disable}"
1311           choosing-strategy: default
1312           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1313
1314     triggers:
1315       - github-pull-request:
1316           trigger-phrase: "^(recheck|reverify)$"
1317           only-trigger-phrase: false
1318           status-context: "PyPI Verify"
1319           permit-all: true
1320           github-hooks: true
1321           white-list-target-branches:
1322             - "{branch}"
1323           included-regions: "{obj:github_included_regions}"
1324
1325 - job-template:
1326     name: "{project-name}-pypi-merge-{stream}"
1327     id: gerrit-pypi-merge
1328     <<: *lf_pypi_common
1329     <<: *lf_pypi_publish_builders
1330
1331     cron: "" # avoid for pypi which rejects duplicates
1332     pypi-repo: pypi-test
1333
1334     scm:
1335       - lf-infra-gerrit-scm:
1336           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1337           git-url: "{git-url}"
1338           refspec: "$GERRIT_REFSPEC"
1339           branch: "$GERRIT_BRANCH"
1340           submodule-recursive: "{submodule-recursive}"
1341           submodule-timeout: "{submodule-timeout}"
1342           submodule-disable: "{submodule-disable}"
1343           # merge jobs always build from tip
1344           choosing-strategy: default
1345
1346     triggers:
1347       - timed: "{obj:cron}"
1348       - gerrit:
1349           server-name: "{gerrit-server-name}"
1350           trigger-on:
1351             - change-merged-event
1352             - comment-added-contains-event:
1353                 comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
1354           projects:
1355             - project-compare-type: ANT
1356               project-pattern: "{project}"
1357               branches:
1358                 - branch-compare-type: ANT
1359                   branch-pattern: "**/{branch}"
1360               file-paths: "{obj:gerrit_trigger_file_paths}"
1361
1362 - job-template:
1363     name: "{project-name}-pypi-merge-{stream}"
1364     id: github-pypi-merge
1365     <<: *lf_pypi_common
1366     <<: *lf_pypi_publish_builders
1367
1368     cron: ""
1369     pypi-repo: pypi-test
1370
1371     properties:
1372       - github:
1373           url: "{github-url}/{github-org}/{project}"
1374
1375     scm:
1376       - lf-infra-github-scm:
1377           url: "{git-clone-url}{github-org}/{project}"
1378           refspec: ""
1379           branch: "refs/heads/{branch}"
1380           submodule-recursive: "{submodule-recursive}"
1381           submodule-timeout: "{submodule-timeout}"
1382           submodule-disable: "{submodule-disable}"
1383           choosing-strategy: default
1384           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1385
1386     triggers:
1387       - timed: "{obj:cron}"
1388       - github-pull-request:
1389           trigger-phrase: "^remerge$"
1390           only-trigger-phrase: false
1391           status-context: "Merge"
1392           permit-all: true
1393           github-hooks: true
1394           org-list:
1395             - "{github-org}"
1396           white-list: "{obj:github_pr_allowlist}"
1397           admin-list: "{obj:github_pr_admin_list}"
1398           white-list-target-branches:
1399             - "{branch}"
1400           included-regions: "{obj:github_included_regions}"
1401
1402 - job-template:
1403     name: "{project-name}-pypi-stage-{stream}"
1404     id: gerrit-pypi-stage
1405     <<: *lf_pypi_common
1406     <<: *lf_pypi_publish_builders
1407
1408     cron: ""
1409     pypi-repo: pypi-test
1410
1411     gerrit_stage_triggers:
1412       - comment-added-contains-event:
1413           comment-contains-value: '^Patch Set\s+\d+:\s+stage-release\s*$'
1414
1415     scm:
1416       - lf-infra-gerrit-scm:
1417           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1418           git-url: "{git-url}"
1419           refspec: "$GERRIT_REFSPEC"
1420           branch: "$GERRIT_BRANCH"
1421           submodule-recursive: "{submodule-recursive}"
1422           submodule-timeout: "{submodule-timeout}"
1423           submodule-disable: "{submodule-disable}"
1424           # stage jobs always build from tip
1425           choosing-strategy: default
1426
1427     triggers:
1428       - timed: "{obj:cron}"
1429       - gerrit:
1430           server-name: "{gerrit-server-name}"
1431           trigger-on: "{obj:gerrit_stage_triggers}"
1432           projects:
1433             - project-compare-type: ANT
1434               project-pattern: "{project}"
1435               branches:
1436                 - branch-compare-type: ANT
1437                   branch-pattern: "**/{branch}"
1438               file-paths: "{obj:gerrit_trigger_file_paths}"
1439
1440 - job-template:
1441     name: "{project-name}-pypi-stage-{stream}"
1442     id: github-pypi-stage
1443     <<: *lf_pypi_common
1444     <<: *lf_pypi_publish_builders
1445
1446     cron: ""
1447     pypi-repo: pypi-test
1448
1449     properties:
1450       - github:
1451           url: "{github-url}/{github-org}/{project}"
1452
1453     scm:
1454       - lf-infra-github-scm:
1455           url: "{git-clone-url}{github-org}/{project}"
1456           refspec: ""
1457           branch: "refs/heads/{branch}"
1458           submodule-recursive: "{submodule-recursive}"
1459           submodule-timeout: "{submodule-timeout}"
1460           submodule-disable: "{submodule-disable}"
1461           choosing-strategy: default
1462           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1463
1464     triggers:
1465       - timed: "{obj:cron}"
1466       - github-pull-request:
1467           trigger-phrase: "^stage-release$"
1468           only-trigger-phrase: true
1469           status-context: "Release"
1470           permit-all: true
1471           github-hooks: true
1472           white-list-target-branches:
1473             - "{branch}"
1474           included-regions: "{obj:github_included_regions}"