Chore: Update Sonar OpenJDK version
[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:
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: openjdk13
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       - lf-sigul-sign-dir:
1221           sign-artifacts: "{sign-artifacts}"
1222           sign-dir: "$WORKSPACE/m2repo"
1223           sign-mode: "{sign-mode}"
1224       # NO lf-maven-stage
1225       # NO lf-maven-central
1226       - lf-provide-maven-settings-cleanup
1227
1228     gerrit_release_docker_triggers:
1229       - comment-added-contains-event:
1230           comment-contains-value: '^Patch Set\s+\d+:\s+stage-(docker-)?release\s*$'
1231
1232 - job-template:
1233     name: "{project-name}-maven-docker-stage-{stream}"
1234     id: gerrit-maven-docker-stage
1235     <<: *lf_maven_common
1236     # yamllint disable-line rule:key-duplicates
1237     <<: *lf_maven_stage
1238     # yamllint disable-line rule:key-duplicates
1239     <<: *lf_maven_docker_stage
1240
1241     scm:
1242       - lf-infra-gerrit-scm:
1243           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1244           git-url: "{git-url}"
1245           refspec: "$GERRIT_REFSPEC"
1246           branch: "$GERRIT_BRANCH"
1247           submodule-recursive: "{submodule-recursive}"
1248           submodule-timeout: "{submodule-timeout}"
1249           submodule-disable: "{submodule-disable}"
1250           choosing-strategy: default
1251
1252     triggers:
1253       - timed: "{obj:cron}"
1254       - gerrit:
1255           server-name: "{gerrit-server-name}"
1256           trigger-on: "{obj:gerrit_release_docker_triggers}"
1257           projects:
1258             - project-compare-type: ANT
1259               project-pattern: "{project}"
1260               branches:
1261                 - branch-compare-type: ANT
1262                   branch-pattern: "**/{branch}"
1263               file-paths: "{obj:gerrit_trigger_file_paths}"
1264
1265 - job-template:
1266     name: "{project-name}-maven-docker-stage-{stream}"
1267     id: github-maven-docker-stage
1268     <<: *lf_maven_common
1269     # yamllint disable-line rule:key-duplicates
1270     <<: *lf_maven_stage
1271     # yamllint disable-line rule:key-duplicates
1272     <<: *lf_maven_docker_stage
1273
1274     properties:
1275       - lf-infra-properties:
1276           build-days-to-keep: "{build-days-to-keep}"
1277       - github:
1278           url: "{github-url}/{github-org}/{project}"
1279
1280     scm:
1281       - lf-infra-github-scm:
1282           url: "{git-clone-url}{github-org}/{project}"
1283           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1284           branch: "{branch}"
1285           submodule-recursive: "{submodule-recursive}"
1286           submodule-timeout: "{submodule-timeout}"
1287           submodule-disable: "{submodule-disable}"
1288           choosing-strategy: default
1289           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1290
1291     triggers:
1292       - timed: "{obj:cron}"
1293       - github-pull-request:
1294           trigger-phrase: "^stage-(docker-)?release$"
1295           only-trigger-phrase: true
1296           status-context: "Maven Release"
1297           permit-all: true
1298           github-hooks: true
1299           white-list-target-branches:
1300             - "{branch}"
1301           included-regions: "{obj:github_included_regions}"
1302
1303 ###############
1304 # Maven Sonar #
1305 ###############
1306
1307 - _lf_maven_sonar: &lf_maven_sonar
1308     name: lf-maven-sonar
1309
1310     ######################
1311     # Default parameters #
1312     ######################
1313
1314     branch: master # Sonar should always be run on master branch
1315     build-days-to-keep: 7
1316     build-timeout: 60
1317     cron: "H H * * 6" # run weekly
1318     disable-job: false
1319     git-url: "$GIT_URL/$PROJECT"
1320     github-url: "https://github.com"
1321     jacoco-exclude-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
1322     java-version: openjdk11
1323     java-opts: ""
1324     mvn-global-settings: global-settings
1325     mvn-goals: clean install
1326     mvn-opts: ""
1327     mvn-params: ""
1328     mvn-version: mvn35
1329     sonar-mvn-goal: "sonar:sonar"
1330     sonarcloud: false
1331     sonarcloud-project-key: ""
1332     sonarcloud-project-organization: ""
1333     sonarcloud-api-token-cred-id: sonarcloud-api-token
1334     sonarcloud-qualitygate-wait: false
1335     # Projects not compatible with jdk13 can set java-version to something else
1336     sonarcloud-java-version: openjdk13
1337     stream: master
1338     submodule-recursive: true
1339     submodule-timeout: 10
1340     submodule-disable: false
1341     scan-dev-branch: false
1342
1343     gerrit_sonar_triggers:
1344       - comment-added-contains-event:
1345           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
1346
1347     #####################
1348     # Job Configuration #
1349     #####################
1350
1351     disabled: "{disable-job}"
1352
1353     parameters:
1354       - lf-infra-parameters:
1355           project: "{project}"
1356           branch: "{branch}"
1357           stream: "{stream}"
1358       - lf-infra-maven-parameters:
1359           mvn-opts: "{mvn-opts}"
1360           mvn-params: "{mvn-params}"
1361           mvn-version: "{mvn-version}"
1362       - string:
1363           name: ARCHIVE_ARTIFACTS
1364           default: "{archive-artifacts}"
1365           description: Artifacts to archive to the logs server.
1366       - string:
1367           name: JAVA_OPTS
1368           default: "{java-opts}"
1369           description: |
1370             Java options. Example: -Xmx1024m
1371       - string:
1372           name: SONAR_MAVEN_GOAL
1373           default: "{sonar-mvn-goal}"
1374           description: |
1375             Maven goals to pass to the Sonar call. Typically sonar:sonar
1376             however to use a specific version of the sonar-maven-plugin we
1377             can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
1378
1379     wrappers:
1380       - credentials-binding:
1381           - text:
1382               credential-id: "{sonarcloud-api-token-cred-id}"
1383               variable: API_TOKEN
1384
1385     triggers:
1386       - timed: "{obj:cron}"
1387       - gerrit:
1388           server-name: "{gerrit-server-name}"
1389           trigger-on: "{obj:gerrit_sonar_triggers}"
1390           projects:
1391             - project-compare-type: "ANT"
1392               project-pattern: "{project}"
1393               branches:
1394                 - branch-compare-type: "ANT"
1395                   branch-pattern: "**/master"
1396           skip-vote:
1397             successful: true
1398             failed: true
1399             unstable: true
1400             notbuilt: true
1401
1402     publishers:
1403       - lf-jacoco-report:
1404           exclude-pattern: "{jacoco-exclude-pattern}"
1405       - findbugs
1406       - lf-infra-publish
1407
1408 - _mvn_sonar_builders: &mvn_sonar_builders
1409     name: mvn-sonar-builders
1410     builders:
1411       - lf-infra-pre-build
1412       # With SonarCloud
1413       - conditional-step:
1414           condition-kind: boolean-expression
1415           condition-expression: "{sonarcloud}"
1416           steps:
1417             - shell: echo 'Using SonarCloud'
1418             - lf-infra-maven-sonarcloud:
1419                 java-version: "{java-version}"
1420                 mvn-goals: "{mvn-goals}"
1421                 mvn-settings: "{mvn-settings}"
1422                 mvn-version: "{mvn-version}"
1423                 sonarcloud-project-key: "{sonarcloud-project-key}"
1424                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
1425                 sonarcloud-java-version: "{sonarcloud-java-version}"
1426                 sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
1427                 scan-dev-branch: "{scan-dev-branch}"
1428       # With SonarQube
1429       - conditional-step:
1430           condition-kind: not
1431           condition-operand:
1432             condition-kind: boolean-expression
1433             condition-expression: "{sonarcloud}"
1434           steps:
1435             - shell: echo 'Using SonarQube'
1436             - lf-infra-maven-sonar:
1437                 java-version: "{java-version}"
1438                 mvn-goals: "{mvn-goals}"
1439                 mvn-settings: "{mvn-settings}"
1440                 mvn-version: "{mvn-version}"
1441
1442 - _mvn_sonar_builders_prescan_script: &mvn_sonar_builders_prescan_script
1443     name: mvn-sonar-builders-prescan-script
1444     builders:
1445       - shell: "{sonar-prescan-script}"
1446       - lf-infra-pre-build
1447       # With SonarCloud
1448       - conditional-step:
1449           condition-kind: boolean-expression
1450           condition-expression: "{sonarcloud}"
1451           steps:
1452             - shell: echo 'Using SonarCloud'
1453             - lf-infra-maven-sonarcloud:
1454                 java-version: "{java-version}"
1455                 mvn-goals: "{mvn-goals}"
1456                 mvn-settings: "{mvn-settings}"
1457                 mvn-version: "{mvn-version}"
1458                 sonarcloud-project-key: "{sonarcloud-project-key}"
1459                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
1460                 sonarcloud-java-version: "{sonarcloud-java-version}"
1461                 sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
1462                 scan-dev-branch: "{scan-dev-branch}"
1463       # With SonarQube
1464       - conditional-step:
1465           condition-kind: not
1466           condition-operand:
1467             condition-kind: boolean-expression
1468             condition-expression: "{sonarcloud}"
1469           steps:
1470             - shell: echo 'Using SonarQube'
1471             - lf-infra-maven-sonar:
1472                 java-version: "{java-version}"
1473                 mvn-goals: "{mvn-goals}"
1474                 mvn-settings: "{mvn-settings}"
1475                 mvn-version: "{mvn-version}"
1476
1477 - builder:
1478     name: lf-infra-maven-sbom-generator
1479     # Run Maven goals and trigger SPDX SBOM Generator tool
1480     builders:
1481       - inject:
1482           properties-content: |
1483             SBOM_FLAGS={sbom-flags}
1484       - shell: !include-raw-escape:
1485           - ../shell/sbom-generator.sh
1486
1487 - builder:
1488     name: lf-infra-maven-sonar
1489     # Run a Sonar build with Maven
1490     builders:
1491       - lf-maven-install:
1492           mvn-version: "{mvn-version}"
1493       - lf-update-java-alternatives:
1494           java-version: "{java-version}"
1495       - inject:
1496           # Switch this to the sonar wrapper when JJB 2.0 is available
1497           properties-content: |
1498             SONAR_HOST_URL=$SONAR_URL
1499             MAVEN_GOALS={mvn-goals}
1500       - lf-provide-maven-settings:
1501           global-settings-file: global-settings
1502           settings-file: "{mvn-settings}"
1503       - shell: !include-raw-escape:
1504           - ../shell/common-variables.sh
1505           - ../shell/maven-sonar.sh
1506       - lf-provide-maven-settings-cleanup
1507
1508 - builder:
1509     name: lf-infra-maven-sonarcloud
1510     # Run a Sonar build with Maven
1511     builders:
1512       - lf-maven-install:
1513           mvn-version: "{mvn-version}"
1514       - lf-update-java-alternatives:
1515           java-version: "{java-version}"
1516       - inject:
1517           # Switch this to the sonar wrapper when JJB 2.0 is available
1518           properties-content: |
1519             SONAR_HOST_URL=https://sonarcloud.io
1520             PROJECT_KEY={sonarcloud-project-key}
1521             PROJECT_ORGANIZATION={sonarcloud-project-organization}
1522             MAVEN_GOALS={mvn-goals}
1523             SONARCLOUD_JAVA_VERSION={sonarcloud-java-version}
1524             SCAN_DEV_BRANCH={scan-dev-branch}
1525             SONARCLOUD_QUALITYGATE_WAIT={sonarcloud-qualitygate-wait}
1526       - lf-provide-maven-settings:
1527           global-settings-file: global-settings
1528           settings-file: "{mvn-settings}"
1529       - shell: !include-raw-escape:
1530           - ../shell/common-variables.sh
1531           - ../shell/maven-sonar.sh
1532       - lf-provide-maven-settings-cleanup
1533
1534 - job-template:
1535     name: "{project-name}-sonar"
1536     id: gerrit-maven-sonar
1537     <<: *lf_maven_common
1538     # yamllint disable-line rule:key-duplicates
1539     <<: *lf_maven_sonar
1540     <<: *mvn_sonar_builders
1541
1542     scm:
1543       - lf-infra-gerrit-scm:
1544           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1545           git-url: "{git-url}"
1546           refspec: $GERRIT_REFSPEC
1547           branch: $GERRIT_BRANCH
1548           submodule-recursive: "{submodule-recursive}"
1549           submodule-timeout: "{submodule-timeout}"
1550           submodule-disable: "{submodule-disable}"
1551           choosing-strategy: default
1552
1553 - job-template:
1554     name: "{project-name}-sonar-verify"
1555     id: gerrit-maven-sonar-verify
1556     <<: *lf_maven_common
1557     # yamllint disable-line rule:key-duplicates
1558     <<: *lf_maven_sonar
1559     <<: *mvn_sonar_builders
1560
1561     sonarcloud: true
1562     scan-dev-branch: true
1563     sonarcloud-qualitygate-wait: false
1564
1565     gerrit_sonar_triggers:
1566       - patchset-created-event:
1567           exclude-drafts: true
1568           exclude-trivial-rebase: false
1569           exclude-no-code-change: false
1570       - draft-published-event
1571       - comment-added-contains-event:
1572           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
1573
1574     gerrit_trigger_file_paths:
1575       - compare-type: REG_EXP
1576         pattern: ".*"
1577
1578     triggers:
1579       - gerrit:
1580           server-name: "{gerrit-server-name}"
1581           trigger-on: "{obj:gerrit_sonar_triggers}"
1582           projects:
1583             - project-compare-type: "ANT"
1584               project-pattern: "{project}"
1585               branches:
1586                 - branch-compare-type: "ANT"
1587                   branch-pattern: "**/{branch}"
1588               file-paths: "{obj:gerrit_trigger_file_paths}"
1589
1590     scm:
1591       - lf-infra-gerrit-scm:
1592           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1593           git-url: "{git-url}"
1594           refspec: $GERRIT_REFSPEC
1595           branch: $GERRIT_BRANCH
1596           submodule-recursive: "{submodule-recursive}"
1597           submodule-timeout: "{submodule-timeout}"
1598           submodule-disable: "{submodule-disable}"
1599           choosing-strategy: gerrit
1600
1601 - job-template:
1602     name: "{project-name}-sonar-prescan-script"
1603     id: gerrit-maven-sonar-prescan-script
1604     <<: *lf_maven_common
1605     # yamllint disable-line rule:key-duplicates
1606     <<: *lf_maven_sonar
1607     <<: *mvn_sonar_builders_prescan_script
1608
1609     scm:
1610       - lf-infra-gerrit-scm:
1611           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1612           git-url: "{git-url}"
1613           refspec: $GERRIT_REFSPEC
1614           branch: $GERRIT_BRANCH
1615           submodule-recursive: "{submodule-recursive}"
1616           submodule-timeout: "{submodule-timeout}"
1617           submodule-disable: "{submodule-disable}"
1618           choosing-strategy: default
1619
1620 - job-template:
1621     name: "{project-name}-sonar"
1622     id: github-maven-sonar
1623     <<: *lf_maven_common
1624     # yamllint disable-line rule:key-duplicates
1625     <<: *lf_maven_sonar
1626
1627     properties:
1628       - lf-infra-properties:
1629           build-days-to-keep: "{build-days-to-keep}"
1630       - github:
1631           url: "{github-url}/{github-org}/{project}"
1632
1633     scm:
1634       - lf-infra-github-scm:
1635           url: "{git-clone-url}{github-org}/{project}"
1636           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1637           branch: "$sha1"
1638           submodule-recursive: "{submodule-recursive}"
1639           submodule-timeout: "{submodule-timeout}"
1640           submodule-disable: "{submodule-disable}"
1641           choosing-strategy: default
1642           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1643
1644     triggers:
1645       - timed: "{obj:cron}"
1646       - github-pull-request:
1647           trigger-phrase: "^run-sonar$"
1648           only-trigger-phrase: true
1649           status-context: "Maven Sonar"
1650           permit-all: true
1651           github-hooks: true
1652           org-list:
1653             - "{github-org}"
1654           white-list: "{obj:github_pr_allowlist}"
1655           admin-list: "{obj:github_pr_admin_list}"
1656           white-list-target-branches:
1657             - "{branch}"
1658
1659 - job-template:
1660     name: "{project-name}-sonar-prescan-script"
1661     id: github-maven-sonar-prescan-script
1662     <<: *lf_maven_common
1663     # yamllint disable-line rule:key-duplicates
1664     <<: *lf_maven_sonar
1665     <<: *mvn_sonar_builders_prescan_script
1666
1667     properties:
1668       - lf-infra-properties:
1669           build-days-to-keep: "{build-days-to-keep}"
1670       - github:
1671           url: "{github-url}/{github-org}/{project}"
1672
1673     scm:
1674       - lf-infra-github-scm:
1675           url: "{git-clone-url}{github-org}/{project}"
1676           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1677           branch: "$sha1"
1678           submodule-recursive: "{submodule-recursive}"
1679           submodule-timeout: "{submodule-timeout}"
1680           submodule-disable: "{submodule-disable}"
1681           choosing-strategy: default
1682           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1683
1684     triggers:
1685       - timed: "{obj:cron}"
1686       - github-pull-request:
1687           trigger-phrase: "^run-sonar$"
1688           only-trigger-phrase: true
1689           status-context: "Maven Sonar"
1690           permit-all: true
1691           github-hooks: true
1692           org-list:
1693             - "{github-org}"
1694           white-list: "{obj:github_pr_allowlist}"
1695           admin-list: "{obj:github_pr_admin_list}"
1696           white-list-target-branches:
1697             - "{branch}"
1698
1699 ################
1700 # Maven Verify #
1701 ################
1702
1703 - _lf_maven_verify: &lf_maven_verify
1704     name: lf-maven-verify
1705
1706     ######################
1707     # Default parameters #
1708     ######################
1709
1710     branch: master
1711     build-days-to-keep: 7
1712     build-timeout: 60
1713     disable-job: false
1714     git-url: "$GIT_URL/$PROJECT"
1715     github-url: "https://github.com"
1716     jacoco-exclude-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
1717     java-version: openjdk11
1718     mvn-global-settings: global-settings
1719     mvn-goals: clean deploy
1720     mvn-opts: ""
1721     mvn-params: "-Dstream=$STREAM -Dmaven.source.skip=true"
1722     mvn-version: mvn35
1723     pre-build-script: "# pre-build script goes here"
1724     post-build-script: "# post-build script goes here"
1725     stream: master
1726     submodule-recursive: true
1727     submodule-timeout: 10
1728     submodule-disable: false
1729
1730     gerrit_verify_triggers:
1731       - patchset-created-event:
1732           exclude-drafts: true
1733           exclude-trivial-rebase: false
1734           exclude-no-code-change: false
1735       - draft-published-event
1736       - comment-added-contains-event:
1737           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
1738
1739     gerrit_trigger_file_paths:
1740       - compare-type: REG_EXP
1741         pattern: ".*"
1742
1743     # github_included_regions MUST match gerrit_trigger_file_paths
1744     github_included_regions:
1745       - ".*"
1746
1747     #####################
1748     # Job Configuration #
1749     #####################
1750
1751     concurrent: true
1752     disabled: "{disable-job}"
1753
1754     builders:
1755       - lf-infra-pre-build
1756       - lf-jacoco-nojava-workaround
1757       - lf-maven-install:
1758           mvn-version: "{mvn-version}"
1759       - lf-update-java-alternatives:
1760           java-version: "{java-version}"
1761       - lf-provide-maven-settings:
1762           global-settings-file: "{mvn-global-settings}"
1763           settings-file: "{mvn-settings}"
1764       - shell: "{pre-build-script}"
1765       - lf-maven-build:
1766           mvn-goals: "{mvn-goals}"
1767       - shell: "{post-build-script}"
1768       - lf-provide-maven-settings-cleanup
1769
1770     publishers:
1771       - findbugs
1772       - lf-jacoco-report:
1773           exclude-pattern: "{jacoco-exclude-pattern}"
1774       - lf-infra-publish
1775
1776 - job-template:
1777     name: "{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}"
1778     id: gerrit-maven-verify
1779     <<: *lf_maven_common
1780     # yamllint disable-line rule:key-duplicates
1781     <<: *lf_maven_verify
1782
1783     scm:
1784       - lf-infra-gerrit-scm:
1785           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1786           git-url: "{git-url}"
1787           refspec: "$GERRIT_REFSPEC"
1788           branch: "$GERRIT_BRANCH"
1789           submodule-recursive: "{submodule-recursive}"
1790           submodule-timeout: "{submodule-timeout}"
1791           submodule-disable: "{submodule-disable}"
1792           choosing-strategy: gerrit
1793
1794     triggers:
1795       - gerrit:
1796           server-name: "{gerrit-server-name}"
1797           trigger-on: "{obj:gerrit_verify_triggers}"
1798           projects:
1799             - project-compare-type: ANT
1800               project-pattern: "{project}"
1801               branches:
1802                 - branch-compare-type: ANT
1803                   branch-pattern: "**/{branch}"
1804               file-paths: "{obj:gerrit_trigger_file_paths}"
1805
1806 - job-template:
1807     name: "{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}"
1808     id: github-maven-verify
1809     <<: *lf_maven_common
1810     # yamllint disable-line rule:key-duplicates
1811     <<: *lf_maven_verify
1812
1813     properties:
1814       - lf-infra-properties:
1815           build-days-to-keep: "{build-days-to-keep}"
1816       - github:
1817           url: "{github-url}/{github-org}/{project}"
1818
1819     scm:
1820       - lf-infra-github-scm:
1821           url: "{git-clone-url}{github-org}/{project}"
1822           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1823           branch: "$sha1"
1824           submodule-recursive: "{submodule-recursive}"
1825           submodule-timeout: "{submodule-timeout}"
1826           submodule-disable: "{submodule-disable}"
1827           choosing-strategy: default
1828           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1829
1830     triggers:
1831       - github-pull-request:
1832           trigger-phrase: "^(recheck|reverify)$"
1833           only-trigger-phrase: false
1834           status-context: "Maven Verify {mvn-version}-{java-version}"
1835           permit-all: true
1836           github-hooks: true
1837           white-list-target-branches:
1838             - "{branch}"
1839           included-regions: "{obj:github_included_regions}"
1840
1841 ###########################
1842 # Maven Verify for Docker #
1843 ###########################
1844
1845 - _lf_maven_docker_verify: &lf_maven_docker_verify
1846     name: lf-maven-docker-verify
1847
1848     # image push not allowed during verification
1849     mvn-goals: clean install
1850
1851     builders:
1852       - lf-infra-pre-build
1853       - lf-jacoco-nojava-workaround
1854       - lf-maven-install:
1855           mvn-version: "{mvn-version}"
1856       - lf-update-java-alternatives:
1857           java-version: "{java-version}"
1858       - lf-infra-docker-login:
1859           global-settings-file: "{mvn-global-settings}"
1860           settings-file: "{mvn-settings}"
1861       # must provide maven settings AFTER docker due to its cleanup
1862       - lf-provide-maven-settings:
1863           global-settings-file: "{mvn-global-settings}"
1864           settings-file: "{mvn-settings}"
1865       - inject:
1866           properties-content: |
1867             CONTAINER_PULL_REGISTRY={container-public-registry}
1868       - lf-maven-build:
1869           mvn-goals: "{mvn-goals}"
1870       - lf-provide-maven-settings-cleanup
1871
1872 - job-template:
1873     name: "{project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}"
1874     id: gerrit-maven-docker-verify
1875     <<: *lf_maven_common
1876     # yamllint disable-line rule:key-duplicates
1877     <<: *lf_maven_verify
1878     # yamllint disable-line rule:key-duplicates
1879     <<: *lf_maven_docker_verify
1880
1881     scm:
1882       - lf-infra-gerrit-scm:
1883           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1884           git-url: "{git-url}"
1885           refspec: "$GERRIT_REFSPEC"
1886           branch: "$GERRIT_BRANCH"
1887           submodule-recursive: "{submodule-recursive}"
1888           submodule-timeout: "{submodule-timeout}"
1889           submodule-disable: "{submodule-disable}"
1890           choosing-strategy: gerrit
1891
1892     triggers:
1893       - gerrit:
1894           server-name: "{gerrit-server-name}"
1895           trigger-on: "{obj:gerrit_verify_triggers}"
1896           projects:
1897             - project-compare-type: ANT
1898               project-pattern: "{project}"
1899               branches:
1900                 - branch-compare-type: ANT
1901                   branch-pattern: "**/{branch}"
1902               file-paths: "{obj:gerrit_trigger_file_paths}"
1903
1904 - job-template:
1905     name: "{project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}"
1906     id: github-maven-docker-verify
1907     <<: *lf_maven_common
1908     # yamllint disable-line rule:key-duplicates
1909     <<: *lf_maven_verify
1910     # yamllint disable-line rule:key-duplicates
1911     <<: *lf_maven_docker_verify
1912
1913     properties:
1914       - lf-infra-properties:
1915           build-days-to-keep: "{build-days-to-keep}"
1916       - github:
1917           url: "{github-url}/{github-org}/{project}"
1918
1919     scm:
1920       - lf-infra-github-scm:
1921           url: "{git-clone-url}{github-org}/{project}"
1922           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1923           branch: "$sha1"
1924           submodule-recursive: "{submodule-recursive}"
1925           submodule-timeout: "{submodule-timeout}"
1926           submodule-disable: "{submodule-disable}"
1927           choosing-strategy: default
1928           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1929
1930     triggers:
1931       - github-pull-request:
1932           trigger-phrase: "^(recheck|reverify)$"
1933           only-trigger-phrase: false
1934           status-context: "Maven Docker Verify {mvn-version}-{java-version}"
1935           permit-all: true
1936           github-hooks: true
1937           white-list-target-branches:
1938             - "{branch}"
1939           included-regions: "{obj:github_included_regions}"
1940
1941 #############################
1942 # Maven Verify Dependencies #
1943 #############################
1944
1945 - _lf_maven_verify_dependencies: &lf_maven_verify_dependencies
1946     name: lf-maven-verify-dependencies
1947
1948     ######################
1949     # Default parameters #
1950     ######################
1951
1952     branch: master
1953     build-days-to-keep: 7
1954     build-timeout: 60
1955     disable-job: false
1956     git-url: "$GIT_URL/$PROJECT"
1957     github-url: "https://github.com"
1958     jacoco-exclude-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
1959     java-version: openjdk11
1960     mvn-global-settings: global-settings
1961     mvn-goals: clean deploy
1962     mvn-opts: ""
1963     mvn-params: "-Dstream=$STREAM"
1964     mvn-version: mvn35
1965     stream: master
1966     submodule-recursive: true
1967     submodule-timeout: 10
1968     submodule-disable: false
1969
1970     gerrit_verify_triggers:
1971       - comment-added-contains-event:
1972           comment-contains-value: "recheck: [0-9 ]+"
1973     gerrit_trigger_file_paths:
1974       - compare-type: ANT
1975         pattern: "**"
1976
1977     #####################
1978     # Job Configuration #
1979     #####################
1980
1981     concurrent: true
1982     disabled: "{disable-job}"
1983
1984     builders:
1985       - lf-infra-pre-build
1986       - lf-jacoco-nojava-workaround
1987       - lf-maven-install:
1988           mvn-version: "{mvn-version}"
1989       - lf-update-java-alternatives:
1990           java-version: "{java-version}"
1991       - lf-provide-maven-settings:
1992           global-settings-file: "{mvn-global-settings}"
1993           settings-file: "{mvn-settings}"
1994       - lf-fetch-dependent-patches
1995       - shell: !include-raw-escape:
1996           - ../shell/common-variables.sh
1997           - ../shell/maven-build-deps.sh
1998       - lf-maven-build:
1999           mvn-goals: "{mvn-goals}"
2000       - lf-provide-maven-settings-cleanup
2001
2002     publishers:
2003       - findbugs
2004       - lf-jacoco-report:
2005           exclude-pattern: "{jacoco-exclude-pattern}"
2006       - lf-infra-publish
2007
2008 - job-template:
2009     name: "{project-name}-maven-verify-deps-{stream}-{mvn-version}-{java-version}"
2010     id: gerrit-maven-verify-dependencies
2011     <<: *lf_maven_common
2012     # yamllint disable-line rule:key-duplicates
2013     <<: *lf_maven_verify_dependencies
2014
2015     scm:
2016       - lf-infra-gerrit-scm:
2017           jenkins-ssh-credential: "{jenkins-ssh-credential}"
2018           git-url: "{git-url}"
2019           refspec: "$GERRIT_REFSPEC"
2020           branch: "$GERRIT_BRANCH"
2021           submodule-recursive: "{submodule-recursive}"
2022           submodule-timeout: "{submodule-timeout}"
2023           submodule-disable: "{submodule-disable}"
2024           choosing-strategy: gerrit
2025
2026     triggers:
2027       - gerrit:
2028           server-name: "{gerrit-server-name}"
2029           trigger-on: "{obj:gerrit_verify_triggers}"
2030           projects:
2031             - project-compare-type: ANT
2032               project-pattern: "{project}"
2033               branches:
2034                 - branch-compare-type: ANT
2035                   branch-pattern: "**/{branch}"
2036               file-paths: "{obj:gerrit_trigger_file_paths}"
2037           comment-text-parameter-mode: PLAIN