Feat!: Upgrade Jenkins-job-builder to 6x
[releng/global-jjb.git] / jjb / lf-maven-jobs.yaml
1 ---
2 # This file contains job templates for Maven projects.
3
4 ##########
5 # Macros #
6 ##########
7
8 - builder:
9     name: lf-maven-build
10     builders:
11       - inject:
12           properties-content: "MAVEN_GOALS={mvn-goals}"
13       - shell: !include-raw-escape:
14           - ../shell/common-variables.sh
15           - ../shell/maven-build.sh
16
17 - builder:
18     name: lf-maven-deploy
19     builders:
20       - shell: !include-raw-escape:
21           - ../shell/common-variables.sh
22           - ../shell/maven-deploy.sh
23
24 - builder:
25     name: lf-maven-versions-plugin
26     builders:
27       - conditional-step:
28           condition-kind: boolean-expression
29           condition-expression: "{maven-versions-plugin}"
30           steps:
31             - inject:
32                 properties-file: "{version-properties-file}"
33             - maven-target:
34                 maven-version: "{mvn-version}"
35                 pom: "{mvn-pom}"
36                 goals: "versions:set versions:update-child-modules versions:commit -B"
37                 properties:
38                   - "newVersion=${{release_version}}"
39                 settings: "{mvn-settings}"
40                 settings-type: cfp
41                 global-settings: "global-settings"
42                 global-settings-type: cfp
43
44 - builder:
45     name: lf-maven-stage
46     builders:
47       - lf-provide-maven-settings:
48           global-settings-file: "{mvn-global-settings}"
49           settings-file: "{mvn-settings}"
50       - lf-infra-create-netrc:
51           server-id: "{mvn-staging-id}"
52       # include-raw-escape fails due to JJB bug
53       - shell: !include-raw-escape:
54           - ../shell/common-variables.sh
55           - ../shell/maven-stage.sh
56       - lf-provide-maven-settings-cleanup
57
58 - builder:
59     name: lf-update-java-alternatives
60     builders:
61       - inject:
62           # Work around inject plugin overriding our GIT_URL variable incorrectly
63           # https://issues.jenkins-ci.org/browse/JENKINS-49775
64           properties-content: |
65             SET_JDK_VERSION={java-version}
66             GIT_URL="$GIT_URL"
67       - shell: !include-raw-escape: ../shell/update-java-alternatives.sh
68       - inject:
69           properties-file: "/tmp/java.env"
70
71 ####################
72 # COMMON FUNCTIONS #
73 ####################
74
75 - _lf_maven_common: &lf_maven_common
76     name: lf-maven-common
77
78     ######################
79     # Default parameters #
80     ######################
81
82     archive-artifacts: >
83       **/*.log
84       **/hs_err_*.log
85       **/target/**/feature.xml
86       **/target/failsafe-reports/failsafe-summary.xml
87       **/target/surefire-reports/*-output.txt
88
89     #####################
90     # Job Configuration #
91     #####################
92
93     project-type: freestyle
94     node: "{build-node}"
95
96     properties:
97       - lf-infra-properties:
98           build-days-to-keep: "{build-days-to-keep}"
99
100     parameters:
101       - lf-infra-parameters:
102           project: "{project}"
103           branch: "{branch}"
104           stream: "{stream}"
105       - lf-infra-maven-parameters:
106           mvn-opts: "{mvn-opts}"
107           mvn-params: "{mvn-params}"
108           mvn-version: "{mvn-version}"
109       - string:
110           name: ARCHIVE_ARTIFACTS
111           default: "{archive-artifacts}"
112           description: Artifacts to archive to the logs server.
113
114     wrappers:
115       - lf-infra-wrappers:
116           build-timeout: "{build-timeout}"
117           jenkins-ssh-credential: "{jenkins-ssh-credential}"
118
119     publishers:
120       # TODO: Make email notification work.
121       # - lf-infra-email-notify:
122       #     email-recipients: '{email-recipients}'
123       #     email-prefix: '[releng]'
124       - lf-infra-publish
125
126 #############
127 # Maven CLM #
128 #############
129
130 - _lf_maven_clm: &lf_maven_clm
131     name: lf-maven-clm
132
133     ######################
134     # Default parameters #
135     ######################
136
137     branch: master
138     build-days-to-keep: 30 # 30 days for troubleshooting purposes
139     build-timeout: 60
140     disable-job: false
141     git-url: "$GIT_URL/$PROJECT"
142     github-url: "https://github.com"
143     java-version: openjdk11
144     mvn-global-settings: global-settings
145     mvn-goals: clean install
146     mvn-opts: ""
147     mvn-params: ""
148     mvn-version: mvn35
149     nexus-iq-namespace: "" # Recommend a trailing dash when set. Example: odl-
150     nexus-iq-stage: "build"
151     stream: master
152     submodule-recursive: true
153     submodule-timeout: 10
154     submodule-disable: false
155
156     nexus_iq_scan_patterns:
157       - "**/*.ear"
158       - "**/*.jar"
159       - "**/*.tar.gz"
160       - "**/*.war"
161       - "**/*.zip"
162
163     gerrit_clm_triggers:
164       - comment-added-contains-event:
165           comment-contains-value: '^Patch Set\s+\d+:\s+run-clm\s*$'
166
167     parameters:
168       - lf-infra-parameters:
169           project: "{project}"
170           branch: "{branch}"
171           stream: "{stream}"
172       - lf-infra-maven-parameters:
173           mvn-opts: "{mvn-opts}"
174           mvn-params: "{mvn-params}"
175           mvn-version: "{mvn-version}"
176       - string:
177           name: ARCHIVE_ARTIFACTS
178           default: "{archive-artifacts}"
179           description: Artifacts to archive to the logs server.
180       - lf-clm-parameters:
181           nexus-iq-stage: "{nexus-iq-stage}"
182
183     #####################
184     # Job Configuration #
185     #####################
186
187     disabled: "{disable-job}"
188
189     builders:
190       - lf-infra-pre-build
191       - lf-maven-install:
192           mvn-version: "{mvn-version}"
193       - lf-update-java-alternatives:
194           java-version: "{java-version}"
195       - lf-provide-maven-settings:
196           global-settings-file: "{mvn-global-settings}"
197           settings-file: "{mvn-settings}"
198       - lf-infra-sonatype-clm:
199           mvn-goals: "{mvn-goals}"
200       - lf-provide-maven-settings-cleanup
201       - shell: 'find . -regex ".*karaf/target" | xargs rm -rf'
202       - nexus-iq-policy-evaluator:
203           stage: "{nexus-iq-stage}"
204           application-type: "manual"
205           application-id: "{nexus-iq-namespace}{project-name}"
206           scan-patterns: "{obj:nexus_iq_scan_patterns}"
207           fail-build-network-error: true
208
209 - builder:
210     name: lf-infra-sonatype-clm
211     # Run a CLM scan build with Maven
212     builders:
213       - inject:
214           properties-content: |
215             MAVEN_GOALS={mvn-goals}
216       - shell: !include-raw-escape:
217           - ../shell/common-variables.sh
218           - ../shell/sonatype-clm.sh
219
220 - job-template:
221     name: "{project-name}-maven-clm-{stream}"
222     id: gerrit-maven-clm
223     <<: *lf_maven_common
224     # yamllint disable-line rule:key-duplicates
225     <<: *lf_maven_clm
226
227     scm:
228       - lf-infra-gerrit-scm:
229           jenkins-ssh-credential: "{jenkins-ssh-credential}"
230           git-url: "{git-url}"
231           refspec: "$GERRIT_REFSPEC"
232           branch: "$GERRIT_BRANCH"
233           submodule-recursive: "{submodule-recursive}"
234           submodule-timeout: "{submodule-timeout}"
235           submodule-disable: "{submodule-disable}"
236           choosing-strategy: default
237
238     triggers:
239       # Build weekly on Saturdays
240       - timed: "H H * * 6"
241       - gerrit:
242           server-name: "{gerrit-server-name}"
243           trigger-on: "{obj:gerrit_clm_triggers}"
244           projects:
245             - project-compare-type: ANT
246               project-pattern: "{project}"
247               branches:
248                 - branch-compare-type: ANT
249                   branch-pattern: "**/{branch}"
250           skip-vote:
251             successful: true
252             failed: true
253             unstable: true
254             notbuilt: true
255
256 - job-template:
257     name: "{project-name}-maven-clm-{stream}"
258     id: github-maven-clm
259     <<: *lf_maven_common
260     # yamllint disable-line rule:key-duplicates
261     <<: *lf_maven_clm
262
263     properties:
264       - lf-infra-properties:
265           build-days-to-keep: "{build-days-to-keep}"
266       - github:
267           url: "{github-url}/{github-org}/{project}"
268
269     scm:
270       - lf-infra-github-scm:
271           url: "{git-clone-url}{github-org}/{project}"
272           refspec: ""
273           branch: "refs/heads/{branch}"
274           submodule-recursive: "{submodule-recursive}"
275           submodule-timeout: "{submodule-timeout}"
276           submodule-disable: "{submodule-disable}"
277           choosing-strategy: default
278           jenkins-ssh-credential: "{jenkins-ssh-credential}"
279
280     triggers:
281       # Build weekly on Saturdays
282       - timed: "H H * * 6"
283       - github-pull-request:
284           trigger-phrase: "^run-clm$"
285           only-trigger-phrase: true
286           status-context: "CLM"
287           permit-all: true
288           github-hooks: true
289           org-list:
290             - "{github-org}"
291           white-list: "{obj:github_pr_allowlist}"
292           admin-list: "{obj:github_pr_admin_list}"
293           white-list-target-branches:
294             - "{branch}"
295
296 ##################
297 # Maven Snyk CLI #
298 ##################
299
300 - _lf_maven_snyk_cli: &lf_maven_snyk_cli
301     name: lf-maven-snyk_cli
302
303     ######################
304     # Default parameters #
305     ######################
306
307     branch: master
308     build-days-to-keep: 30 # 30 days for troubleshooting purposes
309     build-timeout: 60
310     disable-job: false
311     git-url: "$GIT_URL/$PROJECT"
312     github-url: "https://github.com"
313     java-version: openjdk11
314     mvn-global-settings: global-settings
315     mvn-goals: clean install
316     mvn-opts: ""
317     mvn-params: ""
318     mvn-version: mvn35
319     snyk-cli-options: ""
320     snyk-token-credential-id: snyk-token
321     snyk-org-credential-id: snyk-org
322     stream: master
323     submodule-recursive: true
324     submodule-timeout: 10
325     submodule-disable: false
326
327     gerrit_snyk_triggers:
328       - comment-added-contains-event:
329           comment-contains-value: '^Patch Set\s+\d+:\s+run-snyk\s*$'
330
331     parameters:
332       - lf-infra-parameters:
333           project: "{project}"
334           branch: "{branch}"
335           stream: "{stream}"
336       - lf-infra-maven-parameters:
337           mvn-opts: "{mvn-opts}"
338           mvn-params: "{mvn-params}"
339           mvn-version: "{mvn-version}"
340       - string:
341           name: SNYK_CLI_OPTIONS
342           default: "{snyk-cli-options}"
343           description: Additional Snyk CLI commands and options
344       - string:
345           name: ARCHIVE_ARTIFACTS
346           default: "{archive-artifacts}"
347           description: Artifacts to archive to the logs server.
348
349     wrappers:
350       - credentials-binding:
351           - text:
352               credential-id: "{snyk-token-credential-id}"
353               variable: SNYK_TOKEN
354           - text:
355               credential-id: "{snyk-org-credential-id}"
356               variable: SNYK_ORG
357
358     #####################
359     # Job Configuration #
360     #####################
361
362     disabled: "{disable-job}"
363
364     builders:
365       - lf-infra-pre-build
366       - lf-maven-install:
367           mvn-version: "{mvn-version}"
368       - lf-update-java-alternatives:
369           java-version: "{java-version}"
370       - lf-provide-maven-settings:
371           global-settings-file: "{mvn-global-settings}"
372           settings-file: "{mvn-settings}"
373       - lf-maven-build:
374           mvn-goals: "{mvn-goals}"
375       - lf-infra-snyk-cli-scanner
376       - lf-provide-maven-settings-cleanup
377       - shell: 'find . -regex ".*karaf/target" | xargs rm -rf'
378
379 - builder:
380     name: lf-infra-snyk-cli-scanner
381     # Download and run the Snyk CLI scanner
382     builders:
383       - shell: !include-raw-escape:
384           - ../shell/snyk-cli-scanner-run.sh
385
386 - job-template:
387     name: "{project-name}-maven-snyk-cli-{stream}"
388     id: gerrit-maven-snyk-cli
389     <<: *lf_maven_common
390     # yamllint disable-line rule:key-duplicates
391     <<: *lf_maven_snyk_cli
392
393     scm:
394       - lf-infra-gerrit-scm:
395           jenkins-ssh-credential: "{jenkins-ssh-credential}"
396           git-url: "{git-url}"
397           refspec: "$GERRIT_REFSPEC"
398           branch: "$GERRIT_BRANCH"
399           submodule-recursive: "{submodule-recursive}"
400           submodule-timeout: "{submodule-timeout}"
401           submodule-disable: "{submodule-disable}"
402           choosing-strategy: default
403
404     triggers:
405       # Build weekly on Saturdays
406       - timed: "H H * * 6"
407       - gerrit:
408           server-name: "{gerrit-server-name}"
409           trigger-on: "{obj:gerrit_snyk_triggers}"
410           projects:
411             - project-compare-type: ANT
412               project-pattern: "{project}"
413               branches:
414                 - branch-compare-type: ANT
415                   branch-pattern: "**/{branch}"
416           skip-vote:
417             successful: true
418             failed: true
419             unstable: true
420             notbuilt: true
421
422 - job-template:
423     name: "{project-name}-maven-snyk-cli-{stream}"
424     id: github-maven-snyk-cli
425     <<: *lf_maven_common
426     # yamllint disable-line rule:key-duplicates
427     <<: *lf_maven_snyk_cli
428
429     properties:
430       - lf-infra-properties:
431           build-days-to-keep: "{build-days-to-keep}"
432       - github:
433           url: "{github-url}/{github-org}/{project}"
434
435     scm:
436       - lf-infra-github-scm:
437           url: "{git-clone-url}{github-org}/{project}"
438           refspec: ""
439           branch: "refs/heads/{branch}"
440           submodule-recursive: "{submodule-recursive}"
441           submodule-timeout: "{submodule-timeout}"
442           submodule-disable: "{submodule-disable}"
443           choosing-strategy: default
444           jenkins-ssh-credential: "{jenkins-ssh-credential}"
445
446     triggers:
447       # Build weekly on Saturdays
448       - timed: "H H * * 6"
449       - github-pull-request:
450           trigger-phrase: "^run-snyk$"
451           only-trigger-phrase: true
452           status-context: "SNYK scan"
453           permit-all: true
454           github-hooks: true
455           org-list:
456             - "{github-org}"
457           white-list: "{obj:github_pr_allowlist}"
458           admin-list: "{obj:github_pr_admin_list}"
459           white-list-target-branches:
460             - "{branch}"
461
462 #########################
463 # Maven Javadoc Publish #
464 #########################
465
466 - _lf_maven_javadoc_publish: &lf_maven_javadoc_publish
467     name: lf-maven-javadoc-publish
468
469     ######################
470     # Default parameters #
471     ######################
472
473     branch: master
474     build-days-to-keep: 30 # 30 days in case a release takes long to get approved.
475     build-timeout: 60
476     disable-job: false
477     git-url: "$GIT_URL/$PROJECT"
478     github-url: "https://github.com"
479     java-version: openjdk11
480     mvn-dir: "."
481     mvn-global-settings: global-settings
482     mvn-opts: ""
483     mvn-params: ""
484     mvn-version: mvn35
485     stream: master
486     submodule-recursive: true
487     submodule-timeout: 10
488     submodule-disable: false
489
490     gerrit_merge_triggers:
491       - change-merged-event
492       - comment-added-contains-event:
493           comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
494
495     #####################
496     # Job Configuration #
497     #####################
498
499     disabled: "{disable-job}"
500
501     builders:
502       - lf-infra-pre-build
503       - lf-maven-install:
504           mvn-version: "{mvn-version}"
505       - lf-update-java-alternatives:
506           java-version: "{java-version}"
507       - lf-provide-maven-settings:
508           global-settings-file: "{mvn-global-settings}"
509           settings-file: "{mvn-settings}"
510       - lf-infra-create-netrc:
511           server-id: "{mvn-site-id}"
512       - inject:
513           properties-content: |
514             DEPLOY_PATH={javadoc-path}
515             MAVEN_DIR={mvn-dir}
516       - shell: !include-raw-escape:
517           - ../shell/common-variables.sh
518           - ../shell/maven-javadoc-generate.sh
519           - ../shell/maven-javadoc-publish.sh
520       - lf-provide-maven-settings-cleanup
521
522 - job-template:
523     name: "{project-name}-maven-javadoc-publish-{stream}-{java-version}"
524     id: gerrit-maven-javadoc-publish
525     <<: *lf_maven_common
526     # yamllint disable-line rule:key-duplicates
527     <<: *lf_maven_javadoc_publish
528
529     git-url: "$GIT_URL/$GERRIT_PROJECT"
530
531     scm:
532       - lf-infra-gerrit-scm:
533           git-url: "{git-url}"
534           refspec: ""
535           branch: "{branch}"
536           submodule-recursive: "{submodule-recursive}"
537           submodule-timeout: "{submodule-timeout}"
538           submodule-disable: "{submodule-disable}"
539           choosing-strategy: default
540           jenkins-ssh-credential: "{jenkins-ssh-credential}"
541
542     triggers:
543       - gerrit:
544           server-name: "{gerrit-server-name}"
545           trigger-on: "{obj:gerrit_merge_triggers}"
546           projects:
547             - project-compare-type: ANT
548               project-pattern: "{project}"
549               branches:
550                 - branch-compare-type: ANT
551                   branch-pattern: "**/{branch}"
552
553 - job-template:
554     name: "{project-name}-maven-javadoc-publish-{stream}-{java-version}"
555     id: github-maven-javadoc-publish
556     <<: *lf_maven_common
557     # yamllint disable-line rule:key-duplicates
558     <<: *lf_maven_javadoc_publish
559
560     properties:
561       - lf-infra-properties:
562           build-days-to-keep: "{build-days-to-keep}"
563       - github:
564           url: "{github-url}/{github-org}/{project}"
565
566     scm:
567       - lf-infra-github-scm:
568           url: "{git-clone-url}{github-org}/{project}"
569           refspec: ""
570           branch: "{branch}"
571           submodule-recursive: "{submodule-recursive}"
572           submodule-timeout: "{submodule-timeout}"
573           submodule-disable: "{submodule-disable}"
574           choosing-strategy: default
575           jenkins-ssh-credential: "{jenkins-ssh-credential}"
576
577     triggers:
578       - github
579       - pollscm:
580           cron: ""
581       - github-pull-request:
582           trigger-phrase: "^remerge$"
583           only-trigger-phrase: true
584           status-context: "Maven Javadoc Publish"
585           permit-all: true
586           github-hooks: true
587           org-list:
588             - "{github-org}"
589           white-list: "{obj:github_pr_allowlist}"
590           admin-list: "{obj:github_pr_admin_list}"
591           white-list-target-branches:
592             - "{branch}"
593
594 ########################
595 # Maven Javadoc Verify #
596 ########################
597
598 - _lf_maven_javadoc_verify: &lf_maven_javadoc_verify
599     name: lf-maven-javadoc-verify
600
601     ######################
602     # Default parameters #
603     ######################
604
605     branch: master
606     build-days-to-keep: 30 # 30 days in case a release takes long to get approved.
607     build-timeout: 60
608     disable-job: false
609     git-url: "$GIT_URL/$PROJECT"
610     github-url: "https://github.com"
611     java-version: openjdk11
612     mvn-dir: "."
613     mvn-global-settings: global-settings
614     mvn-opts: ""
615     mvn-params: ""
616     mvn-version: mvn35
617     stream: master
618     submodule-recursive: true
619     submodule-timeout: 10
620     submodule-disable: false
621
622     gerrit_verify_triggers:
623       - patchset-created-event:
624           exclude-drafts: true
625           exclude-trivial-rebase: false
626           exclude-no-code-change: false
627       - draft-published-event
628       - comment-added-contains-event:
629           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
630
631     #####################
632     # Job Configuration #
633     #####################
634
635     concurrent: true
636     disabled: "{disable-job}"
637
638     builders:
639       - lf-infra-pre-build
640       - lf-maven-install:
641           mvn-version: "{mvn-version}"
642       - lf-update-java-alternatives:
643           java-version: "{java-version}"
644       - lf-provide-maven-settings:
645           global-settings-file: "{mvn-global-settings}"
646           settings-file: "{mvn-settings}"
647       - inject:
648           properties-content: |
649             MAVEN_DIR={mvn-dir}
650       - shell: !include-raw-escape:
651           - ../shell/common-variables.sh
652           - ../shell/maven-javadoc-generate.sh
653       - lf-provide-maven-settings-cleanup
654
655 - job-template:
656     name: "{project-name}-maven-javadoc-verify-{stream}-{java-version}"
657     id: gerrit-maven-javadoc-verify
658     <<: *lf_maven_common
659     # yamllint disable-line rule:key-duplicates
660     <<: *lf_maven_javadoc_verify
661
662     scm:
663       - lf-infra-gerrit-scm:
664           jenkins-ssh-credential: "{jenkins-ssh-credential}"
665           git-url: "{git-url}"
666           refspec: "$GERRIT_REFSPEC"
667           branch: "$GERRIT_BRANCH"
668           submodule-recursive: "{submodule-recursive}"
669           submodule-timeout: "{submodule-timeout}"
670           submodule-disable: "{submodule-disable}"
671           choosing-strategy: gerrit
672
673     triggers:
674       - gerrit:
675           server-name: "{gerrit-server-name}"
676           trigger-on: "{obj:gerrit_verify_triggers}"
677           projects:
678             - project-compare-type: ANT
679               project-pattern: "{project}"
680               branches:
681                 - branch-compare-type: ANT
682                   branch-pattern: "**/{branch}"
683
684 - job-template:
685     name: "{project-name}-maven-javadoc-verify-{stream}-{java-version}"
686     id: github-maven-javadoc-verify
687     <<: *lf_maven_common
688     # yamllint disable-line rule:key-duplicates
689     <<: *lf_maven_javadoc_verify
690
691     properties:
692       - lf-infra-properties:
693           build-days-to-keep: "{build-days-to-keep}"
694       - github:
695           url: "{github-url}/{github-org}/{project}"
696
697     scm:
698       - lf-infra-github-scm:
699           url: "{git-clone-url}{github-org}/{project}"
700           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
701           branch: "$sha1"
702           submodule-recursive: "{submodule-recursive}"
703           submodule-timeout: "{submodule-timeout}"
704           submodule-disable: "{submodule-disable}"
705           choosing-strategy: default
706           jenkins-ssh-credential: "{jenkins-ssh-credential}"
707
708     triggers:
709       - github-pull-request:
710           trigger-phrase: ^(recheck|reverify)$
711           only-trigger-phrase: false
712           status-context: "Maven Javadoc Verify"
713           permit-all: true
714           github-hooks: true
715           white-list-target-branches:
716             - "{branch}"
717
718 ###############
719 # Maven Merge #
720 ###############
721
722 - _lf_maven_merge: &lf_maven_merge
723     name: lf-maven-merge
724
725     ######################
726     # Default parameters #
727     ######################
728
729     branch: master
730     build-days-to-keep: 30 # 30 days in case we need to troubleshoot
731     build-timeout: 60
732     cron: "@daily"
733     disable-job: false
734     git-url: "$GIT_URL/$PROJECT"
735     github-url: "https://github.com"
736     jacoco-exclude-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
737     java-version: openjdk11
738     mvn-global-settings: global-settings
739     mvn-goals: clean deploy
740     mvn-opts: ""
741     mvn-params: "-Dmerge"
742     mvn-version: mvn35
743     nexus-cut-dirs: 6 # Number of dirs in the Nexus path to remove for wget -r.
744     pre-build-script: "# pre-build script goes here"
745     post-build-script: "# post-build script goes here"
746     stream: master
747     submodule-recursive: true
748     submodule-timeout: 10
749     submodule-disable: false
750
751     gerrit_merge_triggers:
752       - change-merged-event
753       - comment-added-contains-event:
754           comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
755
756     gerrit_trigger_file_paths:
757       - compare-type: REG_EXP
758         pattern: ".*"
759
760     # github_included_regions MUST match gerrit_trigger_file_paths
761     github_included_regions:
762       - ".*"
763
764     post_build_trigger: ""
765
766     #####################
767     # Job Configuration #
768     #####################
769
770     disabled: "{disable-job}"
771
772     builders:
773       - lf-infra-pre-build
774       - lf-jacoco-nojava-workaround
775       - lf-maven-install:
776           mvn-version: "{mvn-version}"
777       - lf-update-java-alternatives:
778           java-version: "{java-version}"
779       - lf-provide-maven-settings:
780           global-settings-file: "{mvn-global-settings}"
781           settings-file: "{mvn-settings}"
782       - lf-infra-create-netrc:
783           server-id: "{mvn-snapshot-id}"
784       - inject:
785           properties-content: |
786             NEXUS_CUT_DIRS={nexus-cut-dirs}
787             NEXUS_REPO={nexus-snapshot-repo}
788       - shell: !include-raw-escape: ../shell/maven-fetch-metadata.sh
789       - shell: "{pre-build-script}"
790       - lf-maven-build:
791           mvn-goals: "{mvn-goals}"
792       - shell: "{post-build-script}"
793       - lf-maven-deploy
794       - lf-provide-maven-settings-cleanup
795
796     publishers:
797       - findbugs
798       - lf-jacoco-report:
799           exclude-pattern: "{jacoco-exclude-pattern}"
800       - lf-infra-publish
801       - trigger-parameterized-builds: "{obj:post_build_trigger}"
802
803 - job-template:
804     name: "{project-name}-maven-merge-{stream}"
805     id: gerrit-maven-merge
806     <<: *lf_maven_common
807     # yamllint disable-line rule:key-duplicates
808     <<: *lf_maven_merge
809
810     scm:
811       - lf-infra-gerrit-scm:
812           jenkins-ssh-credential: "{jenkins-ssh-credential}"
813           git-url: "{git-url}"
814           refspec: "$GERRIT_REFSPEC"
815           branch: "$GERRIT_BRANCH"
816           submodule-recursive: "{submodule-recursive}"
817           submodule-timeout: "{submodule-timeout}"
818           submodule-disable: "{submodule-disable}"
819           choosing-strategy: default
820
821     triggers:
822       - timed: "{obj:cron}"
823       - gerrit:
824           server-name: "{gerrit-server-name}"
825           trigger-on: "{obj:gerrit_merge_triggers}"
826           projects:
827             - project-compare-type: ANT
828               project-pattern: "{project}"
829               branches:
830                 - branch-compare-type: ANT
831                   branch-pattern: "**/{branch}"
832               file-paths: "{obj:gerrit_trigger_file_paths}"
833
834 - job-template:
835     name: "{project-name}-maven-merge-{stream}"
836     id: github-maven-merge
837     <<: *lf_maven_common
838     # yamllint disable-line rule:key-duplicates
839     <<: *lf_maven_merge
840
841     properties:
842       - lf-infra-properties:
843           build-days-to-keep: "{build-days-to-keep}"
844       - github:
845           url: "{github-url}/{github-org}/{project}"
846
847     scm:
848       - lf-infra-github-scm:
849           url: "{git-clone-url}{github-org}/{project}"
850           refspec: ""
851           branch: "refs/heads/{branch}"
852           submodule-recursive: "{submodule-recursive}"
853           submodule-timeout: "{submodule-timeout}"
854           submodule-disable: "{submodule-disable}"
855           choosing-strategy: default
856           jenkins-ssh-credential: "{jenkins-ssh-credential}"
857
858     triggers:
859       - timed: "{obj:cron}"
860       - github
861       - pollscm:
862           cron: ""
863       - github-pull-request:
864           trigger-phrase: "^remerge$"
865           only-trigger-phrase: true
866           status-context: "Maven Merge"
867           permit-all: true
868           github-hooks: true
869           org-list:
870             - "{github-org}"
871           white-list: "{obj:github_pr_allowlist}"
872           admin-list: "{obj:github_pr_admin_list}"
873           white-list-target-branches:
874             - "{branch}"
875           included-regions: "{obj:github_included_regions}"
876
877 ##########################
878 # Maven Merge for Docker #
879 ##########################
880
881 - _lf_maven_docker_merge: &lf_maven_docker_merge
882     name: lf-maven-docker-merge
883
884     builders:
885       - lf-infra-pre-build
886       - lf-jacoco-nojava-workaround
887       - lf-maven-install:
888           mvn-version: "{mvn-version}"
889       - lf-infra-docker-login:
890           global-settings-file: "{mvn-global-settings}"
891           settings-file: "{mvn-settings}"
892       - lf-update-java-alternatives:
893           java-version: "{java-version}"
894       # must provide maven settings AFTER docker due to its cleanup
895       - lf-provide-maven-settings:
896           global-settings-file: "{mvn-global-settings}"
897           settings-file: "{mvn-settings}"
898       - lf-infra-create-netrc:
899           server-id: "{mvn-snapshot-id}"
900       - inject:
901           properties-content: |
902             NEXUS_CUT_DIRS={nexus-cut-dirs}
903             NEXUS_REPO={nexus-snapshot-repo}
904             CONTAINER_PULL_REGISTRY={container-public-registry}
905             CONTAINER_PUSH_REGISTRY={container-snapshot-registry}
906       - shell: !include-raw-escape: ../shell/maven-fetch-metadata.sh
907       - lf-maven-build:
908           mvn-goals: "{mvn-goals}"
909       # NO lf-maven-deploy
910       - lf-provide-maven-settings-cleanup
911
912 - job-template:
913     name: "{project-name}-maven-docker-merge-{stream}"
914     id: gerrit-maven-docker-merge
915     <<: *lf_maven_common
916     # yamllint disable-line rule:key-duplicates
917     <<: *lf_maven_merge
918     # yamllint disable-line rule:key-duplicates
919     <<: *lf_maven_docker_merge
920
921     scm:
922       - lf-infra-gerrit-scm:
923           jenkins-ssh-credential: "{jenkins-ssh-credential}"
924           git-url: "{git-url}"
925           refspec: "$GERRIT_REFSPEC"
926           branch: "$GERRIT_BRANCH"
927           submodule-recursive: "{submodule-recursive}"
928           submodule-timeout: "{submodule-timeout}"
929           submodule-disable: "{submodule-disable}"
930           choosing-strategy: default
931
932     triggers:
933       - gerrit:
934           server-name: "{gerrit-server-name}"
935           trigger-on: "{obj:gerrit_merge_triggers}"
936           projects:
937             - project-compare-type: ANT
938               project-pattern: "{project}"
939               branches:
940                 - branch-compare-type: ANT
941                   branch-pattern: "**/{branch}"
942               file-paths: "{obj:gerrit_trigger_file_paths}"
943
944 - job-template:
945     name: "{project-name}-maven-docker-merge-{stream}"
946     id: github-maven-docker-merge
947     <<: *lf_maven_common
948     # yamllint disable-line rule:key-duplicates
949     <<: *lf_maven_merge
950     # yamllint disable-line rule:key-duplicates
951     <<: *lf_maven_docker_merge
952
953     properties:
954       - lf-infra-properties:
955           build-days-to-keep: "{build-days-to-keep}"
956       - github:
957           url: "{github-url}/{github-org}/{project}"
958
959     scm:
960       - lf-infra-github-scm:
961           url: "{git-clone-url}{github-org}/{project}"
962           refspec: ""
963           branch: "refs/heads/{branch}"
964           submodule-recursive: "{submodule-recursive}"
965           submodule-timeout: "{submodule-timeout}"
966           submodule-disable: "{submodule-disable}"
967           choosing-strategy: default
968           jenkins-ssh-credential: "{jenkins-ssh-credential}"
969
970     triggers:
971       - github
972       - pollscm:
973           cron: ""
974       - github-pull-request:
975           trigger-phrase: "^remerge$"
976           only-trigger-phrase: true
977           status-context: "Maven Docker Merge"
978           permit-all: true
979           github-hooks: true
980           org-list:
981             - "{github-org}"
982           white-list: "{obj:github_pr_allowlist}"
983           admin-list: "{obj:github_pr_admin_list}"
984           white-list-target-branches:
985             - "{branch}"
986           included-regions: "{obj:github_included_regions}"
987
988 ###############
989 # Maven Stage #
990 ###############
991
992 - _lf_maven_stage: &lf_maven_stage
993     name: lf-maven-stage
994
995     ######################
996     # Default parameters #
997     ######################
998
999     branch: master
1000     build-days-to-keep: 30 # 30 days in case a release takes long to get approved.
1001     build-timeout: 60
1002     cron: ""
1003     disable-job: false
1004     git-url: "$GIT_URL/$PROJECT"
1005     github-url: "https://github.com"
1006     java-version: openjdk11
1007     maven-versions-plugin: false
1008     version-properties-file: version.properties
1009     mvn-central: false
1010     mvn-global-settings: global-settings
1011     mvn-goals: clean deploy
1012     mvn-opts: ""
1013     mvn-params: ""
1014     mvn-version: mvn35
1015     ossrh-profile-id: ""
1016     mvn-pom: ""
1017     sbom-flags: ""
1018     sbom-path: "$WORKSPACE"
1019     sbom-generator: false
1020     sbom-generator-version: "v0.0.15"
1021     sign-artifacts: false
1022     sign-mode: serial
1023     stream: master
1024     submodule-recursive: true
1025     submodule-timeout: 10
1026     submodule-disable: false
1027
1028     gerrit_release_triggers:
1029       - comment-added-contains-event:
1030           comment-contains-value: '^Patch Set\s+\d+:\s+stage-(maven-)?release\s*$'
1031
1032     gerrit_trigger_file_paths:
1033       - compare-type: ANT
1034         pattern: "**"
1035
1036     # github_included_regions MUST match gerrit_trigger_file_paths
1037     github_included_regions:
1038       - ".*"
1039
1040     #####################
1041     # Job Configuration #
1042     #####################
1043
1044     disabled: "{disable-job}"
1045
1046     parameters:
1047       - lf-infra-parameters:
1048           project: "{project}"
1049           branch: "{branch}"
1050           stream: "{stream}"
1051       - lf-infra-maven-parameters:
1052           mvn-opts: "{mvn-opts}"
1053           mvn-params: "{mvn-params}"
1054           mvn-version: "{mvn-version}"
1055           staging-profile-id: "{staging-profile-id}"
1056       - bool:
1057           name: MAVEN_VERSIONS_PLUGIN
1058           default: "{maven-versions-plugin}"
1059           description: Use maven-versions-plugin to update pom versions.
1060       - string:
1061           name: ARCHIVE_ARTIFACTS
1062           default: "{archive-artifacts}"
1063           description: Artifacts to archive to the logs server.
1064       - string:
1065           name: STAGING_PROFILE_ID
1066           default: "{staging-profile-id}"
1067           description: Nexus staging profile ID.
1068       - string:
1069           name: SBOM_GENERATOR_VERSION
1070           default: "{sbom-generator-version}"
1071           description: SBOM generator version to download and run.
1072       - string:
1073           name: SBOM_PATH
1074           default: "{sbom-path}"
1075           description: path where SBOM needs to be executed.
1076
1077     builders:
1078       - lf-infra-pre-build
1079       - lf-jacoco-nojava-workaround
1080       - lf-maven-install:
1081           mvn-version: "{mvn-version}"
1082       - lf-update-java-alternatives:
1083           java-version: "{java-version}"
1084       - lf-provide-maven-settings:
1085           global-settings-file: "{mvn-global-settings}"
1086           settings-file: "{mvn-settings}"
1087       - lf-maven-versions-plugin:
1088           maven-versions-plugin: "{maven-versions-plugin}"
1089           version-properties-file: "{version-properties-file}"
1090           mvn-version: "{mvn-version}"
1091           mvn-pom: "{mvn-pom}"
1092           mvn-settings: "{mvn-settings}"
1093       - shell: !include-raw-escape: ../shell/maven-patch-release.sh
1094       - lf-maven-build:
1095           mvn-goals: "{mvn-goals}"
1096       # With SBOM Generator
1097       - conditional-step:
1098           condition-kind: boolean-expression
1099           condition-expression: "{sbom-generator}"
1100           steps:
1101             - shell: echo 'Running SBOM Generator'
1102             - lf-infra-maven-sbom-generator:
1103                 sbom-flags: "{sbom-flags}"
1104       - lf-sigul-sign-dir:
1105           sign-artifacts: "{sign-artifacts}"
1106           sign-dir: "$WORKSPACE/m2repo"
1107           sign-mode: "{sign-mode}"
1108       - lf-maven-stage:
1109           mvn-global-settings: "{mvn-global-settings}"
1110           mvn-settings: "{mvn-settings}"
1111           mvn-staging-id: "{mvn-staging-id}"
1112       - lf-maven-central:
1113           mvn-central: "{mvn-central}"
1114           mvn-global-settings: "{mvn-global-settings}"
1115           mvn-settings: "{mvn-settings}"
1116           ossrh-profile-id: "{ossrh-profile-id}"
1117       - lf-provide-maven-settings-cleanup
1118
1119 - job-template:
1120     name: "{project-name}-maven-stage-{stream}"
1121     id: gerrit-maven-stage
1122     <<: *lf_maven_common
1123     # yamllint disable-line rule:key-duplicates
1124     <<: *lf_maven_stage
1125
1126     scm:
1127       - lf-infra-gerrit-scm:
1128           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1129           git-url: "{git-url}"
1130           refspec: "$GERRIT_REFSPEC"
1131           branch: "$GERRIT_BRANCH"
1132           submodule-recursive: "{submodule-recursive}"
1133           submodule-timeout: "{submodule-timeout}"
1134           submodule-disable: "{submodule-disable}"
1135           choosing-strategy: default
1136
1137     triggers:
1138       - timed: "{obj:cron}"
1139       - gerrit:
1140           server-name: "{gerrit-server-name}"
1141           trigger-on: "{obj:gerrit_release_triggers}"
1142           projects:
1143             - project-compare-type: ANT
1144               project-pattern: "{project}"
1145               branches:
1146                 - branch-compare-type: ANT
1147                   branch-pattern: "**/{branch}"
1148               file-paths: "{obj:gerrit_trigger_file_paths}"
1149
1150 - job-template:
1151     name: "{project-name}-maven-stage-{stream}"
1152     id: github-maven-stage
1153     <<: *lf_maven_common
1154     # yamllint disable-line rule:key-duplicates
1155     <<: *lf_maven_stage
1156
1157     properties:
1158       - lf-infra-properties:
1159           build-days-to-keep: "{build-days-to-keep}"
1160       - github:
1161           url: "{github-url}/{github-org}/{project}"
1162
1163     scm:
1164       - lf-infra-github-scm:
1165           url: "{git-clone-url}{github-org}/{project}"
1166           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1167           branch: "{branch}"
1168           submodule-recursive: "{submodule-recursive}"
1169           submodule-timeout: "{submodule-timeout}"
1170           submodule-disable: "{submodule-disable}"
1171           choosing-strategy: default
1172           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1173
1174     triggers:
1175       - timed: "{obj:cron}"
1176       - github-pull-request:
1177           trigger-phrase: "^stage-(maven-)?release$"
1178           only-trigger-phrase: true
1179           status-context: "Maven Release"
1180           permit-all: true
1181           github-hooks: true
1182           white-list-target-branches:
1183             - "{branch}"
1184           included-regions: "{obj:github_included_regions}"
1185
1186 ##########################
1187 # Maven Stage for Docker #
1188 ##########################
1189
1190 - _lf_maven_docker_stage: &lf_maven_docker_stage
1191     name: lf-maven-docker-stage
1192
1193     builders:
1194       - lf-infra-pre-build
1195       - lf-jacoco-nojava-workaround
1196       - lf-maven-install:
1197           mvn-version: "{mvn-version}"
1198       - lf-update-java-alternatives:
1199           java-version: "{java-version}"
1200       - lf-infra-docker-login:
1201           global-settings-file: "{mvn-global-settings}"
1202           settings-file: "{mvn-settings}"
1203       # must provide maven settings AFTER docker-login due to its cleanup
1204       - lf-provide-maven-settings:
1205           global-settings-file: "{mvn-global-settings}"
1206           settings-file: "{mvn-settings}"
1207       - lf-maven-versions-plugin:
1208           maven-versions-plugin: "{maven-versions-plugin}"
1209           version-properties-file: "{version-properties-file}"
1210           mvn-version: "{mvn-version}"
1211           mvn-pom: "{mvn-pom}"
1212           mvn-settings: "{mvn-settings}"
1213       - shell: !include-raw-escape: ../shell/maven-patch-release.sh
1214       - inject:
1215           properties-content: |
1216             CONTAINER_PULL_REGISTRY={container-public-registry}
1217             CONTAINER_PUSH_REGISTRY={container-staging-registry}
1218       - lf-maven-build:
1219           mvn-goals: "{mvn-goals}"
1220       # With SBOM Generator
1221       - conditional-step:
1222           condition-kind: boolean-expression
1223           condition-expression: "{sbom-generator}"
1224           steps:
1225             - shell: echo 'Running SBOM Generator'
1226             - lf-infra-maven-sbom-generator:
1227                 sbom-flags: "{sbom-flags}"
1228       - lf-sigul-sign-dir:
1229           sign-artifacts: "{sign-artifacts}"
1230           sign-dir: "$WORKSPACE/m2repo"
1231           sign-mode: "{sign-mode}"
1232       # NO lf-maven-stage
1233       # NO lf-maven-central
1234       - lf-provide-maven-settings-cleanup
1235
1236     gerrit_release_docker_triggers:
1237       - comment-added-contains-event:
1238           comment-contains-value: '^Patch Set\s+\d+:\s+stage-(docker-)?release\s*$'
1239
1240 - job-template:
1241     name: "{project-name}-maven-docker-stage-{stream}"
1242     id: gerrit-maven-docker-stage
1243     <<: *lf_maven_common
1244     # yamllint disable-line rule:key-duplicates
1245     <<: *lf_maven_stage
1246     # yamllint disable-line rule:key-duplicates
1247     <<: *lf_maven_docker_stage
1248
1249     scm:
1250       - lf-infra-gerrit-scm:
1251           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1252           git-url: "{git-url}"
1253           refspec: "$GERRIT_REFSPEC"
1254           branch: "$GERRIT_BRANCH"
1255           submodule-recursive: "{submodule-recursive}"
1256           submodule-timeout: "{submodule-timeout}"
1257           submodule-disable: "{submodule-disable}"
1258           choosing-strategy: default
1259
1260     triggers:
1261       - timed: "{obj:cron}"
1262       - gerrit:
1263           server-name: "{gerrit-server-name}"
1264           trigger-on: "{obj:gerrit_release_docker_triggers}"
1265           projects:
1266             - project-compare-type: ANT
1267               project-pattern: "{project}"
1268               branches:
1269                 - branch-compare-type: ANT
1270                   branch-pattern: "**/{branch}"
1271               file-paths: "{obj:gerrit_trigger_file_paths}"
1272
1273 - job-template:
1274     name: "{project-name}-maven-docker-stage-{stream}"
1275     id: github-maven-docker-stage
1276     <<: *lf_maven_common
1277     # yamllint disable-line rule:key-duplicates
1278     <<: *lf_maven_stage
1279     # yamllint disable-line rule:key-duplicates
1280     <<: *lf_maven_docker_stage
1281
1282     properties:
1283       - lf-infra-properties:
1284           build-days-to-keep: "{build-days-to-keep}"
1285       - github:
1286           url: "{github-url}/{github-org}/{project}"
1287
1288     scm:
1289       - lf-infra-github-scm:
1290           url: "{git-clone-url}{github-org}/{project}"
1291           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1292           branch: "{branch}"
1293           submodule-recursive: "{submodule-recursive}"
1294           submodule-timeout: "{submodule-timeout}"
1295           submodule-disable: "{submodule-disable}"
1296           choosing-strategy: default
1297           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1298
1299     triggers:
1300       - timed: "{obj:cron}"
1301       - github-pull-request:
1302           trigger-phrase: "^stage-(docker-)?release$"
1303           only-trigger-phrase: true
1304           status-context: "Maven Release"
1305           permit-all: true
1306           github-hooks: true
1307           white-list-target-branches:
1308             - "{branch}"
1309           included-regions: "{obj:github_included_regions}"
1310
1311 ###############
1312 # Maven Sonar #
1313 ###############
1314
1315 - _lf_maven_sonar: &lf_maven_sonar
1316     name: lf-maven-sonar
1317
1318     ######################
1319     # Default parameters #
1320     ######################
1321
1322     branch: master # Sonar should always be run on master branch
1323     build-days-to-keep: 7
1324     build-timeout: 60
1325     cron: "H H * * 6" # run weekly
1326     disable-job: false
1327     git-url: "$GIT_URL/$PROJECT"
1328     github-url: "https://github.com"
1329     jacoco-exclude-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
1330     java-version: openjdk11
1331     java-opts: ""
1332     mvn-global-settings: global-settings
1333     mvn-goals: clean install
1334     mvn-opts: ""
1335     mvn-params: ""
1336     mvn-version: mvn35
1337     sonar-mvn-goal: "sonar:sonar"
1338     sonarcloud: false
1339     sonarcloud-project-key: ""
1340     sonarcloud-project-organization: ""
1341     sonarcloud-api-token-cred-id: sonarcloud-api-token
1342     sonarcloud-qualitygate-wait: false
1343     # Projects not compatible with jdk17 can set java-version to something else
1344     sonarcloud-java-version: openjdk17
1345     stream: master
1346     submodule-recursive: true
1347     submodule-timeout: 10
1348     submodule-disable: false
1349     scan-dev-branch: false
1350
1351     gerrit_sonar_triggers:
1352       - comment-added-contains-event:
1353           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
1354
1355     #####################
1356     # Job Configuration #
1357     #####################
1358
1359     disabled: "{disable-job}"
1360
1361     parameters:
1362       - lf-infra-parameters:
1363           project: "{project}"
1364           branch: "{branch}"
1365           stream: "{stream}"
1366       - lf-infra-maven-parameters:
1367           mvn-opts: "{mvn-opts}"
1368           mvn-params: "{mvn-params}"
1369           mvn-version: "{mvn-version}"
1370       - string:
1371           name: ARCHIVE_ARTIFACTS
1372           default: "{archive-artifacts}"
1373           description: Artifacts to archive to the logs server.
1374       - string:
1375           name: JAVA_OPTS
1376           default: "{java-opts}"
1377           description: |
1378             Java options. Example: -Xmx1024m
1379       - string:
1380           name: SONAR_MAVEN_GOAL
1381           default: "{sonar-mvn-goal}"
1382           description: |
1383             Maven goals to pass to the Sonar call. Typically sonar:sonar
1384             however to use a specific version of the sonar-maven-plugin we
1385             can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
1386
1387     wrappers:
1388       - credentials-binding:
1389           - text:
1390               credential-id: "{sonarcloud-api-token-cred-id}"
1391               variable: API_TOKEN
1392
1393     triggers:
1394       - timed: "{obj:cron}"
1395       - gerrit:
1396           server-name: "{gerrit-server-name}"
1397           trigger-on: "{obj:gerrit_sonar_triggers}"
1398           projects:
1399             - project-compare-type: "ANT"
1400               project-pattern: "{project}"
1401               branches:
1402                 - branch-compare-type: "ANT"
1403                   branch-pattern: "**/master"
1404           skip-vote:
1405             successful: true
1406             failed: true
1407             unstable: true
1408             notbuilt: true
1409
1410     publishers:
1411       - lf-jacoco-report:
1412           exclude-pattern: "{jacoco-exclude-pattern}"
1413       - findbugs
1414       - lf-infra-publish
1415
1416 - _mvn_sonar_builders: &mvn_sonar_builders
1417     name: mvn-sonar-builders
1418     builders:
1419       - lf-infra-pre-build
1420       # With SonarCloud
1421       - conditional-step:
1422           condition-kind: boolean-expression
1423           condition-expression: "{sonarcloud}"
1424           steps:
1425             - shell: echo 'Using SonarCloud'
1426             - lf-infra-maven-sonarcloud:
1427                 java-version: "{java-version}"
1428                 mvn-goals: "{mvn-goals}"
1429                 mvn-settings: "{mvn-settings}"
1430                 mvn-version: "{mvn-version}"
1431                 sonarcloud-project-key: "{sonarcloud-project-key}"
1432                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
1433                 sonarcloud-java-version: "{sonarcloud-java-version}"
1434                 sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
1435                 scan-dev-branch: "{scan-dev-branch}"
1436       # With SonarQube
1437       - conditional-step:
1438           condition-kind: not
1439           condition-operand:
1440             condition-kind: boolean-expression
1441             condition-expression: "{sonarcloud}"
1442           steps:
1443             - shell: echo 'Using SonarQube'
1444             - lf-infra-maven-sonar:
1445                 java-version: "{java-version}"
1446                 mvn-goals: "{mvn-goals}"
1447                 mvn-settings: "{mvn-settings}"
1448                 mvn-version: "{mvn-version}"
1449
1450 - _mvn_sonar_builders_prescan_script: &mvn_sonar_builders_prescan_script
1451     name: mvn-sonar-builders-prescan-script
1452     builders:
1453       - shell: "{sonar-prescan-script}"
1454       - lf-infra-pre-build
1455       # With SonarCloud
1456       - conditional-step:
1457           condition-kind: boolean-expression
1458           condition-expression: "{sonarcloud}"
1459           steps:
1460             - shell: echo 'Using SonarCloud'
1461             - lf-infra-maven-sonarcloud:
1462                 java-version: "{java-version}"
1463                 mvn-goals: "{mvn-goals}"
1464                 mvn-settings: "{mvn-settings}"
1465                 mvn-version: "{mvn-version}"
1466                 sonarcloud-project-key: "{sonarcloud-project-key}"
1467                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
1468                 sonarcloud-java-version: "{sonarcloud-java-version}"
1469                 sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
1470                 scan-dev-branch: "{scan-dev-branch}"
1471       # With SonarQube
1472       - conditional-step:
1473           condition-kind: not
1474           condition-operand:
1475             condition-kind: boolean-expression
1476             condition-expression: "{sonarcloud}"
1477           steps:
1478             - shell: echo 'Using SonarQube'
1479             - lf-infra-maven-sonar:
1480                 java-version: "{java-version}"
1481                 mvn-goals: "{mvn-goals}"
1482                 mvn-settings: "{mvn-settings}"
1483                 mvn-version: "{mvn-version}"
1484
1485 - builder:
1486     name: lf-infra-maven-sbom-generator
1487     # Run Maven goals and trigger SPDX SBOM Generator tool
1488     builders:
1489       - inject:
1490           properties-content: |
1491             SBOM_FLAGS={sbom-flags}
1492       - shell: !include-raw-escape:
1493           - ../shell/sbom-generator.sh
1494
1495 - builder:
1496     name: lf-infra-maven-sonar
1497     # Run a Sonar build with Maven
1498     builders:
1499       - lf-maven-install:
1500           mvn-version: "{mvn-version}"
1501       - lf-update-java-alternatives:
1502           java-version: "{java-version}"
1503       - inject:
1504           # Switch this to the sonar wrapper when JJB 2.0 is available
1505           properties-content: |
1506             SONAR_HOST_URL=$SONAR_URL
1507             MAVEN_GOALS={mvn-goals}
1508       - lf-provide-maven-settings:
1509           global-settings-file: global-settings
1510           settings-file: "{mvn-settings}"
1511       - shell: !include-raw-escape:
1512           - ../shell/common-variables.sh
1513           - ../shell/maven-sonar.sh
1514       - lf-provide-maven-settings-cleanup
1515
1516 - builder:
1517     name: lf-infra-maven-sonarcloud
1518     # Run a Sonar build with Maven
1519     builders:
1520       - lf-maven-install:
1521           mvn-version: "{mvn-version}"
1522       - lf-update-java-alternatives:
1523           java-version: "{java-version}"
1524       - inject:
1525           # Switch this to the sonar wrapper when JJB 2.0 is available
1526           properties-content: |
1527             SONAR_HOST_URL=https://sonarcloud.io
1528             PROJECT_KEY={sonarcloud-project-key}
1529             PROJECT_ORGANIZATION={sonarcloud-project-organization}
1530             MAVEN_GOALS={mvn-goals}
1531             SONARCLOUD_JAVA_VERSION={sonarcloud-java-version}
1532             SCAN_DEV_BRANCH={scan-dev-branch}
1533             SONARCLOUD_QUALITYGATE_WAIT={sonarcloud-qualitygate-wait}
1534       - lf-provide-maven-settings:
1535           global-settings-file: global-settings
1536           settings-file: "{mvn-settings}"
1537       - shell: !include-raw-escape:
1538           - ../shell/common-variables.sh
1539           - ../shell/maven-sonar.sh
1540       - lf-provide-maven-settings-cleanup
1541
1542 - job-template:
1543     name: "{project-name}-sonar"
1544     id: gerrit-maven-sonar
1545     <<: *lf_maven_common
1546     # yamllint disable-line rule:key-duplicates
1547     <<: *lf_maven_sonar
1548     <<: *mvn_sonar_builders
1549
1550     scm:
1551       - lf-infra-gerrit-scm:
1552           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1553           git-url: "{git-url}"
1554           refspec: $GERRIT_REFSPEC
1555           branch: $GERRIT_BRANCH
1556           submodule-recursive: "{submodule-recursive}"
1557           submodule-timeout: "{submodule-timeout}"
1558           submodule-disable: "{submodule-disable}"
1559           choosing-strategy: default
1560
1561 - job-template:
1562     name: "{project-name}-sonar-verify"
1563     id: gerrit-maven-sonar-verify
1564     <<: *lf_maven_common
1565     # yamllint disable-line rule:key-duplicates
1566     <<: *lf_maven_sonar
1567     <<: *mvn_sonar_builders
1568
1569     sonarcloud: true
1570     scan-dev-branch: true
1571     sonarcloud-qualitygate-wait: false
1572
1573     gerrit_sonar_triggers:
1574       - patchset-created-event:
1575           exclude-drafts: true
1576           exclude-trivial-rebase: false
1577           exclude-no-code-change: false
1578       - draft-published-event
1579       - comment-added-contains-event:
1580           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
1581
1582     gerrit_trigger_file_paths:
1583       - compare-type: REG_EXP
1584         pattern: ".*"
1585
1586     triggers:
1587       - gerrit:
1588           server-name: "{gerrit-server-name}"
1589           trigger-on: "{obj:gerrit_sonar_triggers}"
1590           projects:
1591             - project-compare-type: "ANT"
1592               project-pattern: "{project}"
1593               branches:
1594                 - branch-compare-type: "ANT"
1595                   branch-pattern: "**/{branch}"
1596               file-paths: "{obj:gerrit_trigger_file_paths}"
1597
1598     scm:
1599       - lf-infra-gerrit-scm:
1600           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1601           git-url: "{git-url}"
1602           refspec: $GERRIT_REFSPEC
1603           branch: $GERRIT_BRANCH
1604           submodule-recursive: "{submodule-recursive}"
1605           submodule-timeout: "{submodule-timeout}"
1606           submodule-disable: "{submodule-disable}"
1607           choosing-strategy: gerrit
1608
1609 - job-template:
1610     name: "{project-name}-sonar-prescan-script"
1611     id: gerrit-maven-sonar-prescan-script
1612     <<: *lf_maven_common
1613     # yamllint disable-line rule:key-duplicates
1614     <<: *lf_maven_sonar
1615     <<: *mvn_sonar_builders_prescan_script
1616
1617     scm:
1618       - lf-infra-gerrit-scm:
1619           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1620           git-url: "{git-url}"
1621           refspec: $GERRIT_REFSPEC
1622           branch: $GERRIT_BRANCH
1623           submodule-recursive: "{submodule-recursive}"
1624           submodule-timeout: "{submodule-timeout}"
1625           submodule-disable: "{submodule-disable}"
1626           choosing-strategy: default
1627
1628 - job-template:
1629     name: "{project-name}-sonar"
1630     id: github-maven-sonar
1631     <<: *lf_maven_common
1632     # yamllint disable-line rule:key-duplicates
1633     <<: *lf_maven_sonar
1634
1635     properties:
1636       - lf-infra-properties:
1637           build-days-to-keep: "{build-days-to-keep}"
1638       - github:
1639           url: "{github-url}/{github-org}/{project}"
1640
1641     scm:
1642       - lf-infra-github-scm:
1643           url: "{git-clone-url}{github-org}/{project}"
1644           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1645           branch: "$sha1"
1646           submodule-recursive: "{submodule-recursive}"
1647           submodule-timeout: "{submodule-timeout}"
1648           submodule-disable: "{submodule-disable}"
1649           choosing-strategy: default
1650           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1651
1652     triggers:
1653       - timed: "{obj:cron}"
1654       - github-pull-request:
1655           trigger-phrase: "^run-sonar$"
1656           only-trigger-phrase: true
1657           status-context: "Maven Sonar"
1658           permit-all: true
1659           github-hooks: true
1660           org-list:
1661             - "{github-org}"
1662           white-list: "{obj:github_pr_allowlist}"
1663           admin-list: "{obj:github_pr_admin_list}"
1664           white-list-target-branches:
1665             - "{branch}"
1666
1667 - job-template:
1668     name: "{project-name}-sonar-prescan-script"
1669     id: github-maven-sonar-prescan-script
1670     <<: *lf_maven_common
1671     # yamllint disable-line rule:key-duplicates
1672     <<: *lf_maven_sonar
1673     <<: *mvn_sonar_builders_prescan_script
1674
1675     properties:
1676       - lf-infra-properties:
1677           build-days-to-keep: "{build-days-to-keep}"
1678       - github:
1679           url: "{github-url}/{github-org}/{project}"
1680
1681     scm:
1682       - lf-infra-github-scm:
1683           url: "{git-clone-url}{github-org}/{project}"
1684           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1685           branch: "$sha1"
1686           submodule-recursive: "{submodule-recursive}"
1687           submodule-timeout: "{submodule-timeout}"
1688           submodule-disable: "{submodule-disable}"
1689           choosing-strategy: default
1690           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1691
1692     triggers:
1693       - timed: "{obj:cron}"
1694       - github-pull-request:
1695           trigger-phrase: "^run-sonar$"
1696           only-trigger-phrase: true
1697           status-context: "Maven Sonar"
1698           permit-all: true
1699           github-hooks: true
1700           org-list:
1701             - "{github-org}"
1702           white-list: "{obj:github_pr_allowlist}"
1703           admin-list: "{obj:github_pr_admin_list}"
1704           white-list-target-branches:
1705             - "{branch}"
1706
1707 ################
1708 # Maven Verify #
1709 ################
1710
1711 - _lf_maven_verify: &lf_maven_verify
1712     name: lf-maven-verify
1713
1714     ######################
1715     # Default parameters #
1716     ######################
1717
1718     branch: master
1719     build-days-to-keep: 7
1720     build-timeout: 60
1721     disable-job: false
1722     git-url: "$GIT_URL/$PROJECT"
1723     github-url: "https://github.com"
1724     jacoco-exclude-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
1725     java-version: openjdk11
1726     mvn-global-settings: global-settings
1727     mvn-goals: clean deploy
1728     mvn-opts: ""
1729     mvn-params: "-Dstream=$STREAM -Dmaven.source.skip=true"
1730     mvn-version: mvn35
1731     pre-build-script: "# pre-build script goes here"
1732     post-build-script: "# post-build script goes here"
1733     stream: master
1734     submodule-recursive: true
1735     submodule-timeout: 10
1736     submodule-disable: false
1737
1738     gerrit_verify_triggers:
1739       - patchset-created-event:
1740           exclude-drafts: true
1741           exclude-trivial-rebase: false
1742           exclude-no-code-change: false
1743       - draft-published-event
1744       - comment-added-contains-event:
1745           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
1746
1747     gerrit_trigger_file_paths:
1748       - compare-type: REG_EXP
1749         pattern: ".*"
1750
1751     # github_included_regions MUST match gerrit_trigger_file_paths
1752     github_included_regions:
1753       - ".*"
1754
1755     #####################
1756     # Job Configuration #
1757     #####################
1758
1759     concurrent: true
1760     disabled: "{disable-job}"
1761
1762     builders:
1763       - lf-infra-pre-build
1764       - lf-jacoco-nojava-workaround
1765       - lf-maven-install:
1766           mvn-version: "{mvn-version}"
1767       - lf-update-java-alternatives:
1768           java-version: "{java-version}"
1769       - lf-provide-maven-settings:
1770           global-settings-file: "{mvn-global-settings}"
1771           settings-file: "{mvn-settings}"
1772       - shell: "{pre-build-script}"
1773       - lf-maven-build:
1774           mvn-goals: "{mvn-goals}"
1775       - shell: "{post-build-script}"
1776       - lf-provide-maven-settings-cleanup
1777
1778     publishers:
1779       - findbugs
1780       - lf-jacoco-report:
1781           exclude-pattern: "{jacoco-exclude-pattern}"
1782       - lf-infra-publish
1783
1784 - job-template:
1785     name: "{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}"
1786     id: gerrit-maven-verify
1787     <<: *lf_maven_common
1788     # yamllint disable-line rule:key-duplicates
1789     <<: *lf_maven_verify
1790
1791     scm:
1792       - lf-infra-gerrit-scm:
1793           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1794           git-url: "{git-url}"
1795           refspec: "$GERRIT_REFSPEC"
1796           branch: "$GERRIT_BRANCH"
1797           submodule-recursive: "{submodule-recursive}"
1798           submodule-timeout: "{submodule-timeout}"
1799           submodule-disable: "{submodule-disable}"
1800           choosing-strategy: gerrit
1801
1802     triggers:
1803       - gerrit:
1804           server-name: "{gerrit-server-name}"
1805           trigger-on: "{obj:gerrit_verify_triggers}"
1806           projects:
1807             - project-compare-type: ANT
1808               project-pattern: "{project}"
1809               branches:
1810                 - branch-compare-type: ANT
1811                   branch-pattern: "**/{branch}"
1812               file-paths: "{obj:gerrit_trigger_file_paths}"
1813
1814 - job-template:
1815     name: "{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}"
1816     id: github-maven-verify
1817     <<: *lf_maven_common
1818     # yamllint disable-line rule:key-duplicates
1819     <<: *lf_maven_verify
1820
1821     properties:
1822       - lf-infra-properties:
1823           build-days-to-keep: "{build-days-to-keep}"
1824       - github:
1825           url: "{github-url}/{github-org}/{project}"
1826
1827     scm:
1828       - lf-infra-github-scm:
1829           url: "{git-clone-url}{github-org}/{project}"
1830           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1831           branch: "$sha1"
1832           submodule-recursive: "{submodule-recursive}"
1833           submodule-timeout: "{submodule-timeout}"
1834           submodule-disable: "{submodule-disable}"
1835           choosing-strategy: default
1836           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1837
1838     triggers:
1839       - github-pull-request:
1840           trigger-phrase: "^(recheck|reverify)$"
1841           only-trigger-phrase: false
1842           status-context: "Maven Verify {mvn-version}-{java-version}"
1843           permit-all: true
1844           github-hooks: true
1845           white-list-target-branches:
1846             - "{branch}"
1847           included-regions: "{obj:github_included_regions}"
1848
1849 ###########################
1850 # Maven Verify for Docker #
1851 ###########################
1852
1853 - _lf_maven_docker_verify: &lf_maven_docker_verify
1854     name: lf-maven-docker-verify
1855
1856     # image push not allowed during verification
1857     mvn-goals: clean install
1858
1859     builders:
1860       - lf-infra-pre-build
1861       - lf-jacoco-nojava-workaround
1862       - lf-maven-install:
1863           mvn-version: "{mvn-version}"
1864       - lf-update-java-alternatives:
1865           java-version: "{java-version}"
1866       - lf-infra-docker-login:
1867           global-settings-file: "{mvn-global-settings}"
1868           settings-file: "{mvn-settings}"
1869       # must provide maven settings AFTER docker due to its cleanup
1870       - lf-provide-maven-settings:
1871           global-settings-file: "{mvn-global-settings}"
1872           settings-file: "{mvn-settings}"
1873       - inject:
1874           properties-content: |
1875             CONTAINER_PULL_REGISTRY={container-public-registry}
1876       - lf-maven-build:
1877           mvn-goals: "{mvn-goals}"
1878       - lf-provide-maven-settings-cleanup
1879
1880 - job-template:
1881     name: "{project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}"
1882     id: gerrit-maven-docker-verify
1883     <<: *lf_maven_common
1884     # yamllint disable-line rule:key-duplicates
1885     <<: *lf_maven_verify
1886     # yamllint disable-line rule:key-duplicates
1887     <<: *lf_maven_docker_verify
1888
1889     scm:
1890       - lf-infra-gerrit-scm:
1891           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1892           git-url: "{git-url}"
1893           refspec: "$GERRIT_REFSPEC"
1894           branch: "$GERRIT_BRANCH"
1895           submodule-recursive: "{submodule-recursive}"
1896           submodule-timeout: "{submodule-timeout}"
1897           submodule-disable: "{submodule-disable}"
1898           choosing-strategy: gerrit
1899
1900     triggers:
1901       - gerrit:
1902           server-name: "{gerrit-server-name}"
1903           trigger-on: "{obj:gerrit_verify_triggers}"
1904           projects:
1905             - project-compare-type: ANT
1906               project-pattern: "{project}"
1907               branches:
1908                 - branch-compare-type: ANT
1909                   branch-pattern: "**/{branch}"
1910               file-paths: "{obj:gerrit_trigger_file_paths}"
1911
1912 - job-template:
1913     name: "{project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}"
1914     id: github-maven-docker-verify
1915     <<: *lf_maven_common
1916     # yamllint disable-line rule:key-duplicates
1917     <<: *lf_maven_verify
1918     # yamllint disable-line rule:key-duplicates
1919     <<: *lf_maven_docker_verify
1920
1921     properties:
1922       - lf-infra-properties:
1923           build-days-to-keep: "{build-days-to-keep}"
1924       - github:
1925           url: "{github-url}/{github-org}/{project}"
1926
1927     scm:
1928       - lf-infra-github-scm:
1929           url: "{git-clone-url}{github-org}/{project}"
1930           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1931           branch: "$sha1"
1932           submodule-recursive: "{submodule-recursive}"
1933           submodule-timeout: "{submodule-timeout}"
1934           submodule-disable: "{submodule-disable}"
1935           choosing-strategy: default
1936           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1937
1938     triggers:
1939       - github-pull-request:
1940           trigger-phrase: "^(recheck|reverify)$"
1941           only-trigger-phrase: false
1942           status-context: "Maven Docker Verify {mvn-version}-{java-version}"
1943           permit-all: true
1944           github-hooks: true
1945           white-list-target-branches:
1946             - "{branch}"
1947           included-regions: "{obj:github_included_regions}"
1948
1949 #############################
1950 # Maven Verify Dependencies #
1951 #############################
1952
1953 - _lf_maven_verify_dependencies: &lf_maven_verify_dependencies
1954     name: lf-maven-verify-dependencies
1955
1956     ######################
1957     # Default parameters #
1958     ######################
1959
1960     branch: master
1961     build-days-to-keep: 7
1962     build-timeout: 60
1963     disable-job: false
1964     git-url: "$GIT_URL/$PROJECT"
1965     github-url: "https://github.com"
1966     jacoco-exclude-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
1967     java-version: openjdk11
1968     mvn-global-settings: global-settings
1969     mvn-goals: clean deploy
1970     mvn-opts: ""
1971     mvn-params: "-Dstream=$STREAM"
1972     mvn-version: mvn35
1973     stream: master
1974     submodule-recursive: true
1975     submodule-timeout: 10
1976     submodule-disable: false
1977
1978     gerrit_verify_triggers:
1979       - comment-added-contains-event:
1980           comment-contains-value: "recheck: [0-9 ]+"
1981     gerrit_trigger_file_paths:
1982       - compare-type: ANT
1983         pattern: "**"
1984
1985     #####################
1986     # Job Configuration #
1987     #####################
1988
1989     concurrent: true
1990     disabled: "{disable-job}"
1991
1992     builders:
1993       - lf-infra-pre-build
1994       - lf-jacoco-nojava-workaround
1995       - lf-maven-install:
1996           mvn-version: "{mvn-version}"
1997       - lf-update-java-alternatives:
1998           java-version: "{java-version}"
1999       - lf-provide-maven-settings:
2000           global-settings-file: "{mvn-global-settings}"
2001           settings-file: "{mvn-settings}"
2002       - lf-fetch-dependent-patches
2003       - shell: !include-raw-escape:
2004           - ../shell/common-variables.sh
2005           - ../shell/maven-build-deps.sh
2006       - lf-maven-build:
2007           mvn-goals: "{mvn-goals}"
2008       - lf-provide-maven-settings-cleanup
2009
2010     publishers:
2011       - findbugs
2012       - lf-jacoco-report:
2013           exclude-pattern: "{jacoco-exclude-pattern}"
2014       - lf-infra-publish
2015
2016 - job-template:
2017     name: "{project-name}-maven-verify-deps-{stream}-{mvn-version}-{java-version}"
2018     id: gerrit-maven-verify-dependencies
2019     <<: *lf_maven_common
2020     # yamllint disable-line rule:key-duplicates
2021     <<: *lf_maven_verify_dependencies
2022
2023     scm:
2024       - lf-infra-gerrit-scm:
2025           jenkins-ssh-credential: "{jenkins-ssh-credential}"
2026           git-url: "{git-url}"
2027           refspec: "$GERRIT_REFSPEC"
2028           branch: "$GERRIT_BRANCH"
2029           submodule-recursive: "{submodule-recursive}"
2030           submodule-timeout: "{submodule-timeout}"
2031           submodule-disable: "{submodule-disable}"
2032           choosing-strategy: gerrit
2033
2034     triggers:
2035       - gerrit:
2036           server-name: "{gerrit-server-name}"
2037           trigger-on: "{obj:gerrit_verify_triggers}"
2038           projects:
2039             - project-compare-type: ANT
2040               project-pattern: "{project}"
2041               branches:
2042                 - branch-compare-type: ANT
2043                   branch-pattern: "**/{branch}"
2044               file-paths: "{obj:gerrit_trigger_file_paths}"
2045           comment-text-parameter-mode: PLAIN