Fix: Workaround for yaml multiline string
[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/**,\
737       **/generated-sources/**,\
738       **/yang-gen**,\
739       **/pax/**"
740     java-version: openjdk11
741     mvn-global-settings: global-settings
742     mvn-goals: clean deploy
743     mvn-opts: ""
744     mvn-params: "-Dmerge"
745     mvn-version: mvn35
746     nexus-cut-dirs: 6 # Number of dirs in the Nexus path to remove for wget -r.
747     pre-build-script: "# pre-build script goes here"
748     post-build-script: "# post-build script goes here"
749     stream: master
750     submodule-recursive: true
751     submodule-timeout: 10
752     submodule-disable: false
753
754     gerrit_merge_triggers:
755       - change-merged-event
756       - comment-added-contains-event:
757           comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
758
759     gerrit_trigger_file_paths:
760       - compare-type: REG_EXP
761         pattern: ".*"
762
763     # github_included_regions MUST match gerrit_trigger_file_paths
764     github_included_regions:
765       - ".*"
766
767     post_build_trigger: ""
768
769     #####################
770     # Job Configuration #
771     #####################
772
773     disabled: "{disable-job}"
774
775     builders:
776       - lf-infra-pre-build
777       - lf-jacoco-nojava-workaround
778       - lf-maven-install:
779           mvn-version: "{mvn-version}"
780       - lf-update-java-alternatives:
781           java-version: "{java-version}"
782       - lf-provide-maven-settings:
783           global-settings-file: "{mvn-global-settings}"
784           settings-file: "{mvn-settings}"
785       - lf-infra-create-netrc:
786           server-id: "{mvn-snapshot-id}"
787       - inject:
788           properties-content: |
789             NEXUS_CUT_DIRS={nexus-cut-dirs}
790             NEXUS_REPO={nexus-snapshot-repo}
791       - shell: !include-raw-escape: ../shell/maven-fetch-metadata.sh
792       - shell: "{pre-build-script}"
793       - lf-maven-build:
794           mvn-goals: "{mvn-goals}"
795       - shell: "{post-build-script}"
796       - lf-maven-deploy
797       - lf-provide-maven-settings-cleanup
798
799     publishers:
800       - findbugs
801       - lf-jacoco-report:
802           exclude-pattern: "{jacoco-exclude-pattern}"
803       - lf-infra-publish
804       - trigger-parameterized-builds: "{obj:post_build_trigger}"
805
806 - job-template:
807     name: "{project-name}-maven-merge-{stream}"
808     id: gerrit-maven-merge
809     <<: *lf_maven_common
810     # yamllint disable-line rule:key-duplicates
811     <<: *lf_maven_merge
812
813     scm:
814       - lf-infra-gerrit-scm:
815           jenkins-ssh-credential: "{jenkins-ssh-credential}"
816           git-url: "{git-url}"
817           refspec: "$GERRIT_REFSPEC"
818           branch: "$GERRIT_BRANCH"
819           submodule-recursive: "{submodule-recursive}"
820           submodule-timeout: "{submodule-timeout}"
821           submodule-disable: "{submodule-disable}"
822           choosing-strategy: default
823
824     triggers:
825       - timed: "{obj:cron}"
826       - gerrit:
827           server-name: "{gerrit-server-name}"
828           trigger-on: "{obj:gerrit_merge_triggers}"
829           projects:
830             - project-compare-type: ANT
831               project-pattern: "{project}"
832               branches:
833                 - branch-compare-type: ANT
834                   branch-pattern: "**/{branch}"
835               file-paths: "{obj:gerrit_trigger_file_paths}"
836
837 - job-template:
838     name: "{project-name}-maven-merge-{stream}"
839     id: github-maven-merge
840     <<: *lf_maven_common
841     # yamllint disable-line rule:key-duplicates
842     <<: *lf_maven_merge
843
844     properties:
845       - lf-infra-properties:
846           build-days-to-keep: "{build-days-to-keep}"
847       - github:
848           url: "{github-url}/{github-org}/{project}"
849
850     scm:
851       - lf-infra-github-scm:
852           url: "{git-clone-url}{github-org}/{project}"
853           refspec: ""
854           branch: "refs/heads/{branch}"
855           submodule-recursive: "{submodule-recursive}"
856           submodule-timeout: "{submodule-timeout}"
857           submodule-disable: "{submodule-disable}"
858           choosing-strategy: default
859           jenkins-ssh-credential: "{jenkins-ssh-credential}"
860
861     triggers:
862       - timed: "{obj:cron}"
863       - github
864       - pollscm:
865           cron: ""
866       - github-pull-request:
867           trigger-phrase: "^remerge$"
868           only-trigger-phrase: true
869           status-context: "Maven Merge"
870           permit-all: true
871           github-hooks: true
872           org-list:
873             - "{github-org}"
874           white-list: "{obj:github_pr_allowlist}"
875           admin-list: "{obj:github_pr_admin_list}"
876           white-list-target-branches:
877             - "{branch}"
878           included-regions: "{obj:github_included_regions}"
879
880 ##########################
881 # Maven Merge for Docker #
882 ##########################
883
884 - _lf_maven_docker_merge: &lf_maven_docker_merge
885     name: lf-maven-docker-merge
886
887     builders:
888       - lf-infra-pre-build
889       - lf-jacoco-nojava-workaround
890       - lf-maven-install:
891           mvn-version: "{mvn-version}"
892       - lf-infra-docker-login:
893           global-settings-file: "{mvn-global-settings}"
894           settings-file: "{mvn-settings}"
895       - lf-update-java-alternatives:
896           java-version: "{java-version}"
897       # must provide maven settings AFTER docker due to its cleanup
898       - lf-provide-maven-settings:
899           global-settings-file: "{mvn-global-settings}"
900           settings-file: "{mvn-settings}"
901       - lf-infra-create-netrc:
902           server-id: "{mvn-snapshot-id}"
903       - inject:
904           properties-content: |
905             NEXUS_CUT_DIRS={nexus-cut-dirs}
906             NEXUS_REPO={nexus-snapshot-repo}
907             CONTAINER_PULL_REGISTRY={container-public-registry}
908             CONTAINER_PUSH_REGISTRY={container-snapshot-registry}
909       - shell: !include-raw-escape: ../shell/maven-fetch-metadata.sh
910       - lf-maven-build:
911           mvn-goals: "{mvn-goals}"
912       # NO lf-maven-deploy
913       - lf-provide-maven-settings-cleanup
914
915 - job-template:
916     name: "{project-name}-maven-docker-merge-{stream}"
917     id: gerrit-maven-docker-merge
918     <<: *lf_maven_common
919     # yamllint disable-line rule:key-duplicates
920     <<: *lf_maven_merge
921     # yamllint disable-line rule:key-duplicates
922     <<: *lf_maven_docker_merge
923
924     scm:
925       - lf-infra-gerrit-scm:
926           jenkins-ssh-credential: "{jenkins-ssh-credential}"
927           git-url: "{git-url}"
928           refspec: "$GERRIT_REFSPEC"
929           branch: "$GERRIT_BRANCH"
930           submodule-recursive: "{submodule-recursive}"
931           submodule-timeout: "{submodule-timeout}"
932           submodule-disable: "{submodule-disable}"
933           choosing-strategy: default
934
935     triggers:
936       - gerrit:
937           server-name: "{gerrit-server-name}"
938           trigger-on: "{obj:gerrit_merge_triggers}"
939           projects:
940             - project-compare-type: ANT
941               project-pattern: "{project}"
942               branches:
943                 - branch-compare-type: ANT
944                   branch-pattern: "**/{branch}"
945               file-paths: "{obj:gerrit_trigger_file_paths}"
946
947 - job-template:
948     name: "{project-name}-maven-docker-merge-{stream}"
949     id: github-maven-docker-merge
950     <<: *lf_maven_common
951     # yamllint disable-line rule:key-duplicates
952     <<: *lf_maven_merge
953     # yamllint disable-line rule:key-duplicates
954     <<: *lf_maven_docker_merge
955
956     properties:
957       - lf-infra-properties:
958           build-days-to-keep: "{build-days-to-keep}"
959       - github:
960           url: "{github-url}/{github-org}/{project}"
961
962     scm:
963       - lf-infra-github-scm:
964           url: "{git-clone-url}{github-org}/{project}"
965           refspec: ""
966           branch: "refs/heads/{branch}"
967           submodule-recursive: "{submodule-recursive}"
968           submodule-timeout: "{submodule-timeout}"
969           submodule-disable: "{submodule-disable}"
970           choosing-strategy: default
971           jenkins-ssh-credential: "{jenkins-ssh-credential}"
972
973     triggers:
974       - github
975       - pollscm:
976           cron: ""
977       - github-pull-request:
978           trigger-phrase: "^remerge$"
979           only-trigger-phrase: true
980           status-context: "Maven Docker Merge"
981           permit-all: true
982           github-hooks: true
983           org-list:
984             - "{github-org}"
985           white-list: "{obj:github_pr_allowlist}"
986           admin-list: "{obj:github_pr_admin_list}"
987           white-list-target-branches:
988             - "{branch}"
989           included-regions: "{obj:github_included_regions}"
990
991 ###############
992 # Maven Stage #
993 ###############
994
995 - _lf_maven_stage: &lf_maven_stage
996     name: lf-maven-stage
997
998     ######################
999     # Default parameters #
1000     ######################
1001
1002     branch: master
1003     build-days-to-keep: 30 # 30 days in case a release takes long to get approved.
1004     build-timeout: 60
1005     cron: ""
1006     disable-job: false
1007     git-url: "$GIT_URL/$PROJECT"
1008     github-url: "https://github.com"
1009     java-version: openjdk11
1010     maven-versions-plugin: false
1011     version-properties-file: version.properties
1012     mvn-central: false
1013     mvn-global-settings: global-settings
1014     mvn-goals: clean deploy
1015     mvn-opts: ""
1016     mvn-params: ""
1017     mvn-version: mvn35
1018     ossrh-profile-id: ""
1019     mvn-pom: ""
1020     sbom-flags: ""
1021     sbom-path: "$WORKSPACE"
1022     sbom-generator: false
1023     sbom-generator-version: "v0.0.15"
1024     sign-artifacts: false
1025     sign-mode: serial
1026     stream: master
1027     submodule-recursive: true
1028     submodule-timeout: 10
1029     submodule-disable: false
1030
1031     gerrit_release_triggers:
1032       - comment-added-contains-event:
1033           comment-contains-value: '^Patch Set\s+\d+:\s+stage-(maven-)?release\s*$'
1034
1035     gerrit_trigger_file_paths:
1036       - compare-type: ANT
1037         pattern: "**"
1038
1039     # github_included_regions MUST match gerrit_trigger_file_paths
1040     github_included_regions:
1041       - ".*"
1042
1043     #####################
1044     # Job Configuration #
1045     #####################
1046
1047     disabled: "{disable-job}"
1048
1049     parameters:
1050       - lf-infra-parameters:
1051           project: "{project}"
1052           branch: "{branch}"
1053           stream: "{stream}"
1054       - lf-infra-maven-parameters:
1055           mvn-opts: "{mvn-opts}"
1056           mvn-params: "{mvn-params}"
1057           mvn-version: "{mvn-version}"
1058           staging-profile-id: "{staging-profile-id}"
1059       - bool:
1060           name: MAVEN_VERSIONS_PLUGIN
1061           default: "{maven-versions-plugin}"
1062           description: Use maven-versions-plugin to update pom versions.
1063       - string:
1064           name: ARCHIVE_ARTIFACTS
1065           default: "{archive-artifacts}"
1066           description: Artifacts to archive to the logs server.
1067       - string:
1068           name: STAGING_PROFILE_ID
1069           default: "{staging-profile-id}"
1070           description: Nexus staging profile ID.
1071       - string:
1072           name: SBOM_GENERATOR_VERSION
1073           default: "{sbom-generator-version}"
1074           description: SBOM generator version to download and run.
1075       - string:
1076           name: SBOM_PATH
1077           default: "{sbom-path}"
1078           description: path where SBOM needs to be executed.
1079
1080     builders:
1081       - lf-infra-pre-build
1082       - lf-jacoco-nojava-workaround
1083       - lf-maven-install:
1084           mvn-version: "{mvn-version}"
1085       - lf-update-java-alternatives:
1086           java-version: "{java-version}"
1087       - lf-provide-maven-settings:
1088           global-settings-file: "{mvn-global-settings}"
1089           settings-file: "{mvn-settings}"
1090       - lf-maven-versions-plugin:
1091           maven-versions-plugin: "{maven-versions-plugin}"
1092           version-properties-file: "{version-properties-file}"
1093           mvn-version: "{mvn-version}"
1094           mvn-pom: "{mvn-pom}"
1095           mvn-settings: "{mvn-settings}"
1096       - shell: !include-raw-escape: ../shell/maven-patch-release.sh
1097       - lf-maven-build:
1098           mvn-goals: "{mvn-goals}"
1099       # With SBOM Generator
1100       - conditional-step:
1101           condition-kind: boolean-expression
1102           condition-expression: "{sbom-generator}"
1103           steps:
1104             - shell: echo 'Running SBOM Generator'
1105             - lf-infra-maven-sbom-generator:
1106                 sbom-flags: "{sbom-flags}"
1107       - lf-sigul-sign-dir:
1108           sign-artifacts: "{sign-artifacts}"
1109           sign-dir: "$WORKSPACE/m2repo"
1110           sign-mode: "{sign-mode}"
1111       - lf-maven-stage:
1112           mvn-global-settings: "{mvn-global-settings}"
1113           mvn-settings: "{mvn-settings}"
1114           mvn-staging-id: "{mvn-staging-id}"
1115       - lf-maven-central:
1116           mvn-central: "{mvn-central}"
1117           mvn-global-settings: "{mvn-global-settings}"
1118           mvn-settings: "{mvn-settings}"
1119           ossrh-profile-id: "{ossrh-profile-id}"
1120       - lf-provide-maven-settings-cleanup
1121
1122 - job-template:
1123     name: "{project-name}-maven-stage-{stream}"
1124     id: gerrit-maven-stage
1125     <<: *lf_maven_common
1126     # yamllint disable-line rule:key-duplicates
1127     <<: *lf_maven_stage
1128
1129     scm:
1130       - lf-infra-gerrit-scm:
1131           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1132           git-url: "{git-url}"
1133           refspec: "$GERRIT_REFSPEC"
1134           branch: "$GERRIT_BRANCH"
1135           submodule-recursive: "{submodule-recursive}"
1136           submodule-timeout: "{submodule-timeout}"
1137           submodule-disable: "{submodule-disable}"
1138           choosing-strategy: default
1139
1140     triggers:
1141       - timed: "{obj:cron}"
1142       - gerrit:
1143           server-name: "{gerrit-server-name}"
1144           trigger-on: "{obj:gerrit_release_triggers}"
1145           projects:
1146             - project-compare-type: ANT
1147               project-pattern: "{project}"
1148               branches:
1149                 - branch-compare-type: ANT
1150                   branch-pattern: "**/{branch}"
1151               file-paths: "{obj:gerrit_trigger_file_paths}"
1152
1153 - job-template:
1154     name: "{project-name}-maven-stage-{stream}"
1155     id: github-maven-stage
1156     <<: *lf_maven_common
1157     # yamllint disable-line rule:key-duplicates
1158     <<: *lf_maven_stage
1159
1160     properties:
1161       - lf-infra-properties:
1162           build-days-to-keep: "{build-days-to-keep}"
1163       - github:
1164           url: "{github-url}/{github-org}/{project}"
1165
1166     scm:
1167       - lf-infra-github-scm:
1168           url: "{git-clone-url}{github-org}/{project}"
1169           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1170           branch: "{branch}"
1171           submodule-recursive: "{submodule-recursive}"
1172           submodule-timeout: "{submodule-timeout}"
1173           submodule-disable: "{submodule-disable}"
1174           choosing-strategy: default
1175           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1176
1177     triggers:
1178       - timed: "{obj:cron}"
1179       - github-pull-request:
1180           trigger-phrase: "^stage-(maven-)?release$"
1181           only-trigger-phrase: true
1182           status-context: "Maven Release"
1183           permit-all: true
1184           github-hooks: true
1185           white-list-target-branches:
1186             - "{branch}"
1187           included-regions: "{obj:github_included_regions}"
1188
1189 ##########################
1190 # Maven Stage for Docker #
1191 ##########################
1192
1193 - _lf_maven_docker_stage: &lf_maven_docker_stage
1194     name: lf-maven-docker-stage
1195
1196     builders:
1197       - lf-infra-pre-build
1198       - lf-jacoco-nojava-workaround
1199       - lf-maven-install:
1200           mvn-version: "{mvn-version}"
1201       - lf-update-java-alternatives:
1202           java-version: "{java-version}"
1203       - lf-infra-docker-login:
1204           global-settings-file: "{mvn-global-settings}"
1205           settings-file: "{mvn-settings}"
1206       # must provide maven settings AFTER docker-login due to its cleanup
1207       - lf-provide-maven-settings:
1208           global-settings-file: "{mvn-global-settings}"
1209           settings-file: "{mvn-settings}"
1210       - lf-maven-versions-plugin:
1211           maven-versions-plugin: "{maven-versions-plugin}"
1212           version-properties-file: "{version-properties-file}"
1213           mvn-version: "{mvn-version}"
1214           mvn-pom: "{mvn-pom}"
1215           mvn-settings: "{mvn-settings}"
1216       - shell: !include-raw-escape: ../shell/maven-patch-release.sh
1217       - inject:
1218           properties-content: |
1219             CONTAINER_PULL_REGISTRY={container-public-registry}
1220             CONTAINER_PUSH_REGISTRY={container-staging-registry}
1221       - lf-maven-build:
1222           mvn-goals: "{mvn-goals}"
1223       # With SBOM Generator
1224       - conditional-step:
1225           condition-kind: boolean-expression
1226           condition-expression: "{sbom-generator}"
1227           steps:
1228             - shell: echo 'Running SBOM Generator'
1229             - lf-infra-maven-sbom-generator:
1230                 sbom-flags: "{sbom-flags}"
1231       - lf-sigul-sign-dir:
1232           sign-artifacts: "{sign-artifacts}"
1233           sign-dir: "$WORKSPACE/m2repo"
1234           sign-mode: "{sign-mode}"
1235       # NO lf-maven-stage
1236       # NO lf-maven-central
1237       - lf-provide-maven-settings-cleanup
1238
1239     gerrit_release_docker_triggers:
1240       - comment-added-contains-event:
1241           comment-contains-value: '^Patch Set\s+\d+:\s+stage-(docker-)?release\s*$'
1242
1243 - job-template:
1244     name: "{project-name}-maven-docker-stage-{stream}"
1245     id: gerrit-maven-docker-stage
1246     <<: *lf_maven_common
1247     # yamllint disable-line rule:key-duplicates
1248     <<: *lf_maven_stage
1249     # yamllint disable-line rule:key-duplicates
1250     <<: *lf_maven_docker_stage
1251
1252     scm:
1253       - lf-infra-gerrit-scm:
1254           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1255           git-url: "{git-url}"
1256           refspec: "$GERRIT_REFSPEC"
1257           branch: "$GERRIT_BRANCH"
1258           submodule-recursive: "{submodule-recursive}"
1259           submodule-timeout: "{submodule-timeout}"
1260           submodule-disable: "{submodule-disable}"
1261           choosing-strategy: default
1262
1263     triggers:
1264       - timed: "{obj:cron}"
1265       - gerrit:
1266           server-name: "{gerrit-server-name}"
1267           trigger-on: "{obj:gerrit_release_docker_triggers}"
1268           projects:
1269             - project-compare-type: ANT
1270               project-pattern: "{project}"
1271               branches:
1272                 - branch-compare-type: ANT
1273                   branch-pattern: "**/{branch}"
1274               file-paths: "{obj:gerrit_trigger_file_paths}"
1275
1276 - job-template:
1277     name: "{project-name}-maven-docker-stage-{stream}"
1278     id: github-maven-docker-stage
1279     <<: *lf_maven_common
1280     # yamllint disable-line rule:key-duplicates
1281     <<: *lf_maven_stage
1282     # yamllint disable-line rule:key-duplicates
1283     <<: *lf_maven_docker_stage
1284
1285     properties:
1286       - lf-infra-properties:
1287           build-days-to-keep: "{build-days-to-keep}"
1288       - github:
1289           url: "{github-url}/{github-org}/{project}"
1290
1291     scm:
1292       - lf-infra-github-scm:
1293           url: "{git-clone-url}{github-org}/{project}"
1294           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1295           branch: "{branch}"
1296           submodule-recursive: "{submodule-recursive}"
1297           submodule-timeout: "{submodule-timeout}"
1298           submodule-disable: "{submodule-disable}"
1299           choosing-strategy: default
1300           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1301
1302     triggers:
1303       - timed: "{obj:cron}"
1304       - github-pull-request:
1305           trigger-phrase: "^stage-(docker-)?release$"
1306           only-trigger-phrase: true
1307           status-context: "Maven Release"
1308           permit-all: true
1309           github-hooks: true
1310           white-list-target-branches:
1311             - "{branch}"
1312           included-regions: "{obj:github_included_regions}"
1313
1314 ###############
1315 # Maven Sonar #
1316 ###############
1317
1318 - _lf_maven_sonar: &lf_maven_sonar
1319     name: lf-maven-sonar
1320
1321     ######################
1322     # Default parameters #
1323     ######################
1324
1325     branch: master # Sonar should always be run on master branch
1326     build-days-to-keep: 7
1327     build-timeout: 60
1328     cron: "H H * * 6" # run weekly
1329     disable-job: false
1330     git-url: "$GIT_URL/$PROJECT"
1331     github-url: "https://github.com"
1332     jacoco-exclude-pattern: "**/gen/**,\
1333       **/generated-sources/**,\
1334       **/yang-gen**,\
1335       **/pax/**"
1336     java-version: openjdk11
1337     java-opts: ""
1338     mvn-global-settings: global-settings
1339     mvn-goals: clean install
1340     mvn-opts: ""
1341     mvn-params: ""
1342     mvn-version: mvn35
1343     sonar-mvn-goal: "sonar:sonar"
1344     sonarcloud: false
1345     sonarcloud-project-key: ""
1346     sonarcloud-project-organization: ""
1347     sonarcloud-api-token-cred-id: sonarcloud-api-token
1348     sonarcloud-qualitygate-wait: false
1349     # Projects not compatible with jdk17 can set java-version to something else
1350     sonarcloud-java-version: openjdk17
1351     stream: master
1352     submodule-recursive: true
1353     submodule-timeout: 10
1354     submodule-disable: false
1355     scan-dev-branch: false
1356
1357     gerrit_sonar_triggers:
1358       - comment-added-contains-event:
1359           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
1360
1361     #####################
1362     # Job Configuration #
1363     #####################
1364
1365     disabled: "{disable-job}"
1366
1367     parameters:
1368       - lf-infra-parameters:
1369           project: "{project}"
1370           branch: "{branch}"
1371           stream: "{stream}"
1372       - lf-infra-maven-parameters:
1373           mvn-opts: "{mvn-opts}"
1374           mvn-params: "{mvn-params}"
1375           mvn-version: "{mvn-version}"
1376       - string:
1377           name: ARCHIVE_ARTIFACTS
1378           default: "{archive-artifacts}"
1379           description: Artifacts to archive to the logs server.
1380       - string:
1381           name: JAVA_OPTS
1382           default: "{java-opts}"
1383           description: |
1384             Java options. Example: -Xmx1024m
1385       - string:
1386           name: SONAR_MAVEN_GOAL
1387           default: "{sonar-mvn-goal}"
1388           description: |
1389             Maven goals to pass to the Sonar call. Typically sonar:sonar
1390             however to use a specific version of the sonar-maven-plugin we
1391             can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
1392
1393     wrappers:
1394       - credentials-binding:
1395           - text:
1396               credential-id: "{sonarcloud-api-token-cred-id}"
1397               variable: API_TOKEN
1398
1399     triggers:
1400       - timed: "{obj:cron}"
1401       - gerrit:
1402           server-name: "{gerrit-server-name}"
1403           trigger-on: "{obj:gerrit_sonar_triggers}"
1404           projects:
1405             - project-compare-type: "ANT"
1406               project-pattern: "{project}"
1407               branches:
1408                 - branch-compare-type: "ANT"
1409                   branch-pattern: "**/master"
1410           skip-vote:
1411             successful: true
1412             failed: true
1413             unstable: true
1414             notbuilt: true
1415
1416     publishers:
1417       - lf-jacoco-report:
1418           exclude-pattern: "{jacoco-exclude-pattern}"
1419       - findbugs
1420       - lf-infra-publish
1421
1422 - _mvn_sonar_builders: &mvn_sonar_builders
1423     name: mvn-sonar-builders
1424     builders:
1425       - lf-infra-pre-build
1426       # With SonarCloud
1427       - conditional-step:
1428           condition-kind: boolean-expression
1429           condition-expression: "{sonarcloud}"
1430           steps:
1431             - shell: echo 'Using SonarCloud'
1432             - lf-infra-maven-sonarcloud:
1433                 java-version: "{java-version}"
1434                 mvn-goals: "{mvn-goals}"
1435                 mvn-settings: "{mvn-settings}"
1436                 mvn-version: "{mvn-version}"
1437                 sonarcloud-project-key: "{sonarcloud-project-key}"
1438                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
1439                 sonarcloud-java-version: "{sonarcloud-java-version}"
1440                 sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
1441                 scan-dev-branch: "{scan-dev-branch}"
1442       # With SonarQube
1443       - conditional-step:
1444           condition-kind: not
1445           condition-operand:
1446             condition-kind: boolean-expression
1447             condition-expression: "{sonarcloud}"
1448           steps:
1449             - shell: echo 'Using SonarQube'
1450             - lf-infra-maven-sonar:
1451                 java-version: "{java-version}"
1452                 mvn-goals: "{mvn-goals}"
1453                 mvn-settings: "{mvn-settings}"
1454                 mvn-version: "{mvn-version}"
1455
1456 - _mvn_sonar_builders_prescan_script: &mvn_sonar_builders_prescan_script
1457     name: mvn-sonar-builders-prescan-script
1458     builders:
1459       - shell: "{sonar-prescan-script}"
1460       - lf-infra-pre-build
1461       # With SonarCloud
1462       - conditional-step:
1463           condition-kind: boolean-expression
1464           condition-expression: "{sonarcloud}"
1465           steps:
1466             - shell: echo 'Using SonarCloud'
1467             - lf-infra-maven-sonarcloud:
1468                 java-version: "{java-version}"
1469                 mvn-goals: "{mvn-goals}"
1470                 mvn-settings: "{mvn-settings}"
1471                 mvn-version: "{mvn-version}"
1472                 sonarcloud-project-key: "{sonarcloud-project-key}"
1473                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
1474                 sonarcloud-java-version: "{sonarcloud-java-version}"
1475                 sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
1476                 scan-dev-branch: "{scan-dev-branch}"
1477       # With SonarQube
1478       - conditional-step:
1479           condition-kind: not
1480           condition-operand:
1481             condition-kind: boolean-expression
1482             condition-expression: "{sonarcloud}"
1483           steps:
1484             - shell: echo 'Using SonarQube'
1485             - lf-infra-maven-sonar:
1486                 java-version: "{java-version}"
1487                 mvn-goals: "{mvn-goals}"
1488                 mvn-settings: "{mvn-settings}"
1489                 mvn-version: "{mvn-version}"
1490
1491 - builder:
1492     name: lf-infra-maven-sbom-generator
1493     # Run Maven goals and trigger SPDX SBOM Generator tool
1494     builders:
1495       - inject:
1496           properties-content: |
1497             SBOM_FLAGS={sbom-flags}
1498       - shell: !include-raw-escape:
1499           - ../shell/sbom-generator.sh
1500
1501 - builder:
1502     name: lf-infra-maven-sonar
1503     # Run a Sonar build with Maven
1504     builders:
1505       - lf-maven-install:
1506           mvn-version: "{mvn-version}"
1507       - lf-update-java-alternatives:
1508           java-version: "{java-version}"
1509       - inject:
1510           # Switch this to the sonar wrapper when JJB 2.0 is available
1511           properties-content: |
1512             SONAR_HOST_URL=$SONAR_URL
1513             MAVEN_GOALS={mvn-goals}
1514       - lf-provide-maven-settings:
1515           global-settings-file: global-settings
1516           settings-file: "{mvn-settings}"
1517       - shell: !include-raw-escape:
1518           - ../shell/common-variables.sh
1519           - ../shell/maven-sonar.sh
1520       - lf-provide-maven-settings-cleanup
1521
1522 - builder:
1523     name: lf-infra-maven-sonarcloud
1524     # Run a Sonar build with Maven
1525     builders:
1526       - lf-maven-install:
1527           mvn-version: "{mvn-version}"
1528       - lf-update-java-alternatives:
1529           java-version: "{java-version}"
1530       - inject:
1531           # Switch this to the sonar wrapper when JJB 2.0 is available
1532           properties-content: |
1533             SONAR_HOST_URL=https://sonarcloud.io
1534             PROJECT_KEY={sonarcloud-project-key}
1535             PROJECT_ORGANIZATION={sonarcloud-project-organization}
1536             MAVEN_GOALS={mvn-goals}
1537             SONARCLOUD_JAVA_VERSION={sonarcloud-java-version}
1538             SCAN_DEV_BRANCH={scan-dev-branch}
1539             SONARCLOUD_QUALITYGATE_WAIT={sonarcloud-qualitygate-wait}
1540       - lf-provide-maven-settings:
1541           global-settings-file: global-settings
1542           settings-file: "{mvn-settings}"
1543       - shell: !include-raw-escape:
1544           - ../shell/common-variables.sh
1545           - ../shell/maven-sonar.sh
1546       - lf-provide-maven-settings-cleanup
1547
1548 - job-template:
1549     name: "{project-name}-sonar"
1550     id: gerrit-maven-sonar
1551     <<: *lf_maven_common
1552     # yamllint disable-line rule:key-duplicates
1553     <<: *lf_maven_sonar
1554     <<: *mvn_sonar_builders
1555
1556     scm:
1557       - lf-infra-gerrit-scm:
1558           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1559           git-url: "{git-url}"
1560           refspec: $GERRIT_REFSPEC
1561           branch: $GERRIT_BRANCH
1562           submodule-recursive: "{submodule-recursive}"
1563           submodule-timeout: "{submodule-timeout}"
1564           submodule-disable: "{submodule-disable}"
1565           choosing-strategy: default
1566
1567 - job-template:
1568     name: "{project-name}-sonar-verify"
1569     id: gerrit-maven-sonar-verify
1570     <<: *lf_maven_common
1571     # yamllint disable-line rule:key-duplicates
1572     <<: *lf_maven_sonar
1573     <<: *mvn_sonar_builders
1574
1575     sonarcloud: true
1576     scan-dev-branch: true
1577     sonarcloud-qualitygate-wait: false
1578
1579     gerrit_sonar_triggers:
1580       - patchset-created-event:
1581           exclude-drafts: true
1582           exclude-trivial-rebase: false
1583           exclude-no-code-change: false
1584       - draft-published-event
1585       - comment-added-contains-event:
1586           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
1587
1588     gerrit_trigger_file_paths:
1589       - compare-type: REG_EXP
1590         pattern: ".*"
1591
1592     triggers:
1593       - gerrit:
1594           server-name: "{gerrit-server-name}"
1595           trigger-on: "{obj:gerrit_sonar_triggers}"
1596           projects:
1597             - project-compare-type: "ANT"
1598               project-pattern: "{project}"
1599               branches:
1600                 - branch-compare-type: "ANT"
1601                   branch-pattern: "**/{branch}"
1602               file-paths: "{obj:gerrit_trigger_file_paths}"
1603
1604     scm:
1605       - lf-infra-gerrit-scm:
1606           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1607           git-url: "{git-url}"
1608           refspec: $GERRIT_REFSPEC
1609           branch: $GERRIT_BRANCH
1610           submodule-recursive: "{submodule-recursive}"
1611           submodule-timeout: "{submodule-timeout}"
1612           submodule-disable: "{submodule-disable}"
1613           choosing-strategy: gerrit
1614
1615 - job-template:
1616     name: "{project-name}-sonar-prescan-script"
1617     id: gerrit-maven-sonar-prescan-script
1618     <<: *lf_maven_common
1619     # yamllint disable-line rule:key-duplicates
1620     <<: *lf_maven_sonar
1621     <<: *mvn_sonar_builders_prescan_script
1622
1623     scm:
1624       - lf-infra-gerrit-scm:
1625           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1626           git-url: "{git-url}"
1627           refspec: $GERRIT_REFSPEC
1628           branch: $GERRIT_BRANCH
1629           submodule-recursive: "{submodule-recursive}"
1630           submodule-timeout: "{submodule-timeout}"
1631           submodule-disable: "{submodule-disable}"
1632           choosing-strategy: default
1633
1634 - job-template:
1635     name: "{project-name}-sonar"
1636     id: github-maven-sonar
1637     <<: *lf_maven_common
1638     # yamllint disable-line rule:key-duplicates
1639     <<: *lf_maven_sonar
1640
1641     properties:
1642       - lf-infra-properties:
1643           build-days-to-keep: "{build-days-to-keep}"
1644       - github:
1645           url: "{github-url}/{github-org}/{project}"
1646
1647     scm:
1648       - lf-infra-github-scm:
1649           url: "{git-clone-url}{github-org}/{project}"
1650           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1651           branch: "$sha1"
1652           submodule-recursive: "{submodule-recursive}"
1653           submodule-timeout: "{submodule-timeout}"
1654           submodule-disable: "{submodule-disable}"
1655           choosing-strategy: default
1656           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1657
1658     triggers:
1659       - timed: "{obj:cron}"
1660       - github-pull-request:
1661           trigger-phrase: "^run-sonar$"
1662           only-trigger-phrase: true
1663           status-context: "Maven Sonar"
1664           permit-all: true
1665           github-hooks: true
1666           org-list:
1667             - "{github-org}"
1668           white-list: "{obj:github_pr_allowlist}"
1669           admin-list: "{obj:github_pr_admin_list}"
1670           white-list-target-branches:
1671             - "{branch}"
1672
1673 - job-template:
1674     name: "{project-name}-sonar-prescan-script"
1675     id: github-maven-sonar-prescan-script
1676     <<: *lf_maven_common
1677     # yamllint disable-line rule:key-duplicates
1678     <<: *lf_maven_sonar
1679     <<: *mvn_sonar_builders_prescan_script
1680
1681     properties:
1682       - lf-infra-properties:
1683           build-days-to-keep: "{build-days-to-keep}"
1684       - github:
1685           url: "{github-url}/{github-org}/{project}"
1686
1687     scm:
1688       - lf-infra-github-scm:
1689           url: "{git-clone-url}{github-org}/{project}"
1690           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1691           branch: "$sha1"
1692           submodule-recursive: "{submodule-recursive}"
1693           submodule-timeout: "{submodule-timeout}"
1694           submodule-disable: "{submodule-disable}"
1695           choosing-strategy: default
1696           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1697
1698     triggers:
1699       - timed: "{obj:cron}"
1700       - github-pull-request:
1701           trigger-phrase: "^run-sonar$"
1702           only-trigger-phrase: true
1703           status-context: "Maven Sonar"
1704           permit-all: true
1705           github-hooks: true
1706           org-list:
1707             - "{github-org}"
1708           white-list: "{obj:github_pr_allowlist}"
1709           admin-list: "{obj:github_pr_admin_list}"
1710           white-list-target-branches:
1711             - "{branch}"
1712
1713 ################
1714 # Maven Verify #
1715 ################
1716
1717 - _lf_maven_verify: &lf_maven_verify
1718     name: lf-maven-verify
1719
1720     ######################
1721     # Default parameters #
1722     ######################
1723
1724     branch: master
1725     build-days-to-keep: 7
1726     build-timeout: 60
1727     disable-job: false
1728     git-url: "$GIT_URL/$PROJECT"
1729     github-url: "https://github.com"
1730     jacoco-exclude-pattern: "**/gen/**,\
1731       **/generated-sources/**,\
1732       **/yang-gen**,\
1733       **/pax/**"
1734     java-version: openjdk11
1735     mvn-global-settings: global-settings
1736     mvn-goals: clean deploy
1737     mvn-opts: ""
1738     mvn-params: "-Dstream=$STREAM -Dmaven.source.skip=true"
1739     mvn-version: mvn35
1740     pre-build-script: "# pre-build script goes here"
1741     post-build-script: "# post-build script goes here"
1742     stream: master
1743     submodule-recursive: true
1744     submodule-timeout: 10
1745     submodule-disable: false
1746
1747     gerrit_verify_triggers:
1748       - patchset-created-event:
1749           exclude-drafts: true
1750           exclude-trivial-rebase: false
1751           exclude-no-code-change: false
1752       - draft-published-event
1753       - comment-added-contains-event:
1754           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
1755
1756     gerrit_trigger_file_paths:
1757       - compare-type: REG_EXP
1758         pattern: ".*"
1759
1760     # github_included_regions MUST match gerrit_trigger_file_paths
1761     github_included_regions:
1762       - ".*"
1763
1764     #####################
1765     # Job Configuration #
1766     #####################
1767
1768     concurrent: true
1769     disabled: "{disable-job}"
1770
1771     builders:
1772       - lf-infra-pre-build
1773       - lf-jacoco-nojava-workaround
1774       - lf-maven-install:
1775           mvn-version: "{mvn-version}"
1776       - lf-update-java-alternatives:
1777           java-version: "{java-version}"
1778       - lf-provide-maven-settings:
1779           global-settings-file: "{mvn-global-settings}"
1780           settings-file: "{mvn-settings}"
1781       - shell: "{pre-build-script}"
1782       - lf-maven-build:
1783           mvn-goals: "{mvn-goals}"
1784       - shell: "{post-build-script}"
1785       - lf-provide-maven-settings-cleanup
1786
1787     publishers:
1788       - findbugs
1789       - lf-jacoco-report:
1790           exclude-pattern: "{jacoco-exclude-pattern}"
1791       - lf-infra-publish
1792
1793 - job-template:
1794     name: "{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}"
1795     id: gerrit-maven-verify
1796     <<: *lf_maven_common
1797     # yamllint disable-line rule:key-duplicates
1798     <<: *lf_maven_verify
1799
1800     scm:
1801       - lf-infra-gerrit-scm:
1802           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1803           git-url: "{git-url}"
1804           refspec: "$GERRIT_REFSPEC"
1805           branch: "$GERRIT_BRANCH"
1806           submodule-recursive: "{submodule-recursive}"
1807           submodule-timeout: "{submodule-timeout}"
1808           submodule-disable: "{submodule-disable}"
1809           choosing-strategy: gerrit
1810
1811     triggers:
1812       - gerrit:
1813           server-name: "{gerrit-server-name}"
1814           trigger-on: "{obj:gerrit_verify_triggers}"
1815           projects:
1816             - project-compare-type: ANT
1817               project-pattern: "{project}"
1818               branches:
1819                 - branch-compare-type: ANT
1820                   branch-pattern: "**/{branch}"
1821               file-paths: "{obj:gerrit_trigger_file_paths}"
1822
1823 - job-template:
1824     name: "{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}"
1825     id: github-maven-verify
1826     <<: *lf_maven_common
1827     # yamllint disable-line rule:key-duplicates
1828     <<: *lf_maven_verify
1829
1830     properties:
1831       - lf-infra-properties:
1832           build-days-to-keep: "{build-days-to-keep}"
1833       - github:
1834           url: "{github-url}/{github-org}/{project}"
1835
1836     scm:
1837       - lf-infra-github-scm:
1838           url: "{git-clone-url}{github-org}/{project}"
1839           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1840           branch: "$sha1"
1841           submodule-recursive: "{submodule-recursive}"
1842           submodule-timeout: "{submodule-timeout}"
1843           submodule-disable: "{submodule-disable}"
1844           choosing-strategy: default
1845           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1846
1847     triggers:
1848       - github-pull-request:
1849           trigger-phrase: "^(recheck|reverify)$"
1850           only-trigger-phrase: false
1851           status-context: "Maven Verify {mvn-version}-{java-version}"
1852           permit-all: true
1853           github-hooks: true
1854           white-list-target-branches:
1855             - "{branch}"
1856           included-regions: "{obj:github_included_regions}"
1857
1858 ###########################
1859 # Maven Verify for Docker #
1860 ###########################
1861
1862 - _lf_maven_docker_verify: &lf_maven_docker_verify
1863     name: lf-maven-docker-verify
1864
1865     # image push not allowed during verification
1866     mvn-goals: clean install
1867
1868     builders:
1869       - lf-infra-pre-build
1870       - lf-jacoco-nojava-workaround
1871       - lf-maven-install:
1872           mvn-version: "{mvn-version}"
1873       - lf-update-java-alternatives:
1874           java-version: "{java-version}"
1875       - lf-infra-docker-login:
1876           global-settings-file: "{mvn-global-settings}"
1877           settings-file: "{mvn-settings}"
1878       # must provide maven settings AFTER docker due to its cleanup
1879       - lf-provide-maven-settings:
1880           global-settings-file: "{mvn-global-settings}"
1881           settings-file: "{mvn-settings}"
1882       - inject:
1883           properties-content: |
1884             CONTAINER_PULL_REGISTRY={container-public-registry}
1885       - lf-maven-build:
1886           mvn-goals: "{mvn-goals}"
1887       - lf-provide-maven-settings-cleanup
1888
1889 - job-template:
1890     name: "{project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}"
1891     id: gerrit-maven-docker-verify
1892     <<: *lf_maven_common
1893     # yamllint disable-line rule:key-duplicates
1894     <<: *lf_maven_verify
1895     # yamllint disable-line rule:key-duplicates
1896     <<: *lf_maven_docker_verify
1897
1898     scm:
1899       - lf-infra-gerrit-scm:
1900           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1901           git-url: "{git-url}"
1902           refspec: "$GERRIT_REFSPEC"
1903           branch: "$GERRIT_BRANCH"
1904           submodule-recursive: "{submodule-recursive}"
1905           submodule-timeout: "{submodule-timeout}"
1906           submodule-disable: "{submodule-disable}"
1907           choosing-strategy: gerrit
1908
1909     triggers:
1910       - gerrit:
1911           server-name: "{gerrit-server-name}"
1912           trigger-on: "{obj:gerrit_verify_triggers}"
1913           projects:
1914             - project-compare-type: ANT
1915               project-pattern: "{project}"
1916               branches:
1917                 - branch-compare-type: ANT
1918                   branch-pattern: "**/{branch}"
1919               file-paths: "{obj:gerrit_trigger_file_paths}"
1920
1921 - job-template:
1922     name: "{project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}"
1923     id: github-maven-docker-verify
1924     <<: *lf_maven_common
1925     # yamllint disable-line rule:key-duplicates
1926     <<: *lf_maven_verify
1927     # yamllint disable-line rule:key-duplicates
1928     <<: *lf_maven_docker_verify
1929
1930     properties:
1931       - lf-infra-properties:
1932           build-days-to-keep: "{build-days-to-keep}"
1933       - github:
1934           url: "{github-url}/{github-org}/{project}"
1935
1936     scm:
1937       - lf-infra-github-scm:
1938           url: "{git-clone-url}{github-org}/{project}"
1939           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1940           branch: "$sha1"
1941           submodule-recursive: "{submodule-recursive}"
1942           submodule-timeout: "{submodule-timeout}"
1943           submodule-disable: "{submodule-disable}"
1944           choosing-strategy: default
1945           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1946
1947     triggers:
1948       - github-pull-request:
1949           trigger-phrase: "^(recheck|reverify)$"
1950           only-trigger-phrase: false
1951           status-context: "Maven Docker Verify {mvn-version}-{java-version}"
1952           permit-all: true
1953           github-hooks: true
1954           white-list-target-branches:
1955             - "{branch}"
1956           included-regions: "{obj:github_included_regions}"
1957
1958 #############################
1959 # Maven Verify Dependencies #
1960 #############################
1961
1962 - _lf_maven_verify_dependencies: &lf_maven_verify_dependencies
1963     name: lf-maven-verify-dependencies
1964
1965     ######################
1966     # Default parameters #
1967     ######################
1968
1969     branch: master
1970     build-days-to-keep: 7
1971     build-timeout: 60
1972     disable-job: false
1973     git-url: "$GIT_URL/$PROJECT"
1974     github-url: "https://github.com"
1975     jacoco-exclude-pattern: "**/gen/**,\
1976       **/generated-sources/**,\
1977       **/yang-gen**,\
1978       **/pax/**"
1979     java-version: openjdk11
1980     mvn-global-settings: global-settings
1981     mvn-goals: clean deploy
1982     mvn-opts: ""
1983     mvn-params: "-Dstream=$STREAM"
1984     mvn-version: mvn35
1985     stream: master
1986     submodule-recursive: true
1987     submodule-timeout: 10
1988     submodule-disable: false
1989
1990     gerrit_verify_triggers:
1991       - comment-added-contains-event:
1992           comment-contains-value: "recheck: [0-9 ]+"
1993     gerrit_trigger_file_paths:
1994       - compare-type: ANT
1995         pattern: "**"
1996
1997     #####################
1998     # Job Configuration #
1999     #####################
2000
2001     concurrent: true
2002     disabled: "{disable-job}"
2003
2004     builders:
2005       - lf-infra-pre-build
2006       - lf-jacoco-nojava-workaround
2007       - lf-maven-install:
2008           mvn-version: "{mvn-version}"
2009       - lf-update-java-alternatives:
2010           java-version: "{java-version}"
2011       - lf-provide-maven-settings:
2012           global-settings-file: "{mvn-global-settings}"
2013           settings-file: "{mvn-settings}"
2014       - lf-fetch-dependent-patches
2015       - shell: !include-raw-escape:
2016           - ../shell/common-variables.sh
2017           - ../shell/maven-build-deps.sh
2018       - lf-maven-build:
2019           mvn-goals: "{mvn-goals}"
2020       - lf-provide-maven-settings-cleanup
2021
2022     publishers:
2023       - findbugs
2024       - lf-jacoco-report:
2025           exclude-pattern: "{jacoco-exclude-pattern}"
2026       - lf-infra-publish
2027
2028 - job-template:
2029     name: "{project-name}-maven-verify-deps-{stream}-{mvn-version}-{java-version}"
2030     id: gerrit-maven-verify-dependencies
2031     <<: *lf_maven_common
2032     # yamllint disable-line rule:key-duplicates
2033     <<: *lf_maven_verify_dependencies
2034
2035     scm:
2036       - lf-infra-gerrit-scm:
2037           jenkins-ssh-credential: "{jenkins-ssh-credential}"
2038           git-url: "{git-url}"
2039           refspec: "$GERRIT_REFSPEC"
2040           branch: "$GERRIT_BRANCH"
2041           submodule-recursive: "{submodule-recursive}"
2042           submodule-timeout: "{submodule-timeout}"
2043           submodule-disable: "{submodule-disable}"
2044           choosing-strategy: gerrit
2045
2046     triggers:
2047       - gerrit:
2048           server-name: "{gerrit-server-name}"
2049           trigger-on: "{obj:gerrit_verify_triggers}"
2050           projects:
2051             - project-compare-type: ANT
2052               project-pattern: "{project}"
2053               branches:
2054                 - branch-compare-type: ANT
2055                   branch-pattern: "**/{branch}"
2056               file-paths: "{obj:gerrit_trigger_file_paths}"
2057           comment-text-parameter-mode: PLAIN