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