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