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