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