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