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