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