5dbeef2d91ffc7ad43c4b08f90129b51542157b7
[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: ""
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     triggers:
1212       - timed: "{obj:cron}"
1213       - gerrit:
1214           server-name: "{gerrit-server-name}"
1215           trigger-on: "{obj:gerrit_sonar_triggers}"
1216           projects:
1217             - project-compare-type: "ANT"
1218               project-pattern: "{project}"
1219               branches:
1220                 - branch-compare-type: "ANT"
1221                   branch-pattern: "**/master"
1222           skip-vote:
1223             successful: true
1224             failed: true
1225             unstable: true
1226             notbuilt: true
1227
1228     publishers:
1229       - lf-jacoco-report
1230       - findbugs
1231       - lf-infra-publish
1232
1233 - mvn_sonar_builders: &mvn_sonar_builders
1234     name: mvn-sonar-builders
1235     builders:
1236       - lf-infra-pre-build
1237       # With SonarCloud
1238       - conditional-step:
1239           condition-kind: boolean-expression
1240           condition-expression: "{sonarcloud}"
1241           steps:
1242             - shell: echo 'Using SonarCloud'
1243             - lf-infra-maven-sonarcloud:
1244                 java-version: "{java-version}"
1245                 mvn-goals: "{mvn-goals}"
1246                 mvn-settings: "{mvn-settings}"
1247                 mvn-version: "{mvn-version}"
1248                 sonarcloud-project-key: "{sonarcloud-project-key}"
1249                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
1250                 sonarcloud-api-token: "{sonarcloud-api-token}"
1251                 sonarcloud-java-version: "{sonarcloud-java-version}"
1252                 sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
1253                 scan-dev-branch: "{scan-dev-branch}"
1254       # With SonarQube
1255       - conditional-step:
1256           condition-kind: not
1257           condition-operand:
1258             condition-kind: boolean-expression
1259             condition-expression: "{sonarcloud}"
1260           steps:
1261             - shell: echo 'Using SonarQube'
1262             - lf-infra-maven-sonar:
1263                 java-version: "{java-version}"
1264                 mvn-goals: "{mvn-goals}"
1265                 mvn-settings: "{mvn-settings}"
1266                 mvn-version: "{mvn-version}"
1267
1268 - mvn_sonar_builders_prescan_script: &mvn_sonar_builders_prescan_script
1269     name: mvn-sonar-builders-prescan-script
1270     builders:
1271       - shell: "{sonar-prescan-script}"
1272       - lf-infra-pre-build
1273       # With SonarCloud
1274       - conditional-step:
1275           condition-kind: boolean-expression
1276           condition-expression: "{sonarcloud}"
1277           steps:
1278             - shell: echo 'Using SonarCloud'
1279             - lf-infra-maven-sonarcloud:
1280                 java-version: "{java-version}"
1281                 mvn-goals: "{mvn-goals}"
1282                 mvn-settings: "{mvn-settings}"
1283                 mvn-version: "{mvn-version}"
1284                 sonarcloud-project-key: "{sonarcloud-project-key}"
1285                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
1286                 sonarcloud-api-token: "{sonarcloud-api-token}"
1287                 sonarcloud-java-version: "{sonarcloud-java-version}"
1288                 sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
1289                 scan-dev-branch: "{scan-dev-branch}"
1290       # With SonarQube
1291       - conditional-step:
1292           condition-kind: not
1293           condition-operand:
1294             condition-kind: boolean-expression
1295             condition-expression: "{sonarcloud}"
1296           steps:
1297             - shell: echo 'Using SonarQube'
1298             - lf-infra-maven-sonar:
1299                 java-version: "{java-version}"
1300                 mvn-goals: "{mvn-goals}"
1301                 mvn-settings: "{mvn-settings}"
1302                 mvn-version: "{mvn-version}"
1303
1304 - builder:
1305     name: lf-infra-maven-sbom-generator
1306     # Run Maven goals and trigger SPDX SBOM Generator tool
1307     builders:
1308       - inject:
1309           properties-content: |
1310             SBOM_FLAGS={sbom-flags}
1311       - shell: !include-raw-escape:
1312           - ../shell/sbom-generator.sh
1313
1314 - builder:
1315     name: lf-infra-maven-sonar
1316     # Run a Sonar build with Maven
1317     builders:
1318       - lf-maven-install:
1319           mvn-version: "{mvn-version}"
1320       - lf-update-java-alternatives:
1321           java-version: "{java-version}"
1322       - inject:
1323           # Switch this to the sonar wrapper when JJB 2.0 is available
1324           properties-content: |
1325             SONAR_HOST_URL=$SONAR_URL
1326             MAVEN_GOALS={mvn-goals}
1327       - lf-provide-maven-settings:
1328           global-settings-file: global-settings
1329           settings-file: "{mvn-settings}"
1330       - shell: !include-raw-escape:
1331           - ../shell/common-variables.sh
1332           - ../shell/maven-sonar.sh
1333       - lf-provide-maven-settings-cleanup
1334
1335 - builder:
1336     name: lf-infra-maven-sonarcloud
1337     # Run a Sonar build with Maven
1338     builders:
1339       - lf-maven-install:
1340           mvn-version: "{mvn-version}"
1341       - lf-update-java-alternatives:
1342           java-version: "{java-version}"
1343       - inject:
1344           # Switch this to the sonar wrapper when JJB 2.0 is available
1345           properties-content: |
1346             SONAR_HOST_URL=https://sonarcloud.io
1347             PROJECT_KEY={sonarcloud-project-key}
1348             PROJECT_ORGANIZATION={sonarcloud-project-organization}
1349             MAVEN_GOALS={mvn-goals}
1350             API_TOKEN={sonarcloud-api-token}
1351             SONARCLOUD_JAVA_VERSION={sonarcloud-java-version}
1352             SCAN_DEV_BRANCH={scan-dev-branch}
1353             SONARCLOUD_QUALITYGATE_WAIT={sonarcloud-qualitygate-wait}
1354       - lf-provide-maven-settings:
1355           global-settings-file: global-settings
1356           settings-file: "{mvn-settings}"
1357       - shell: !include-raw-escape:
1358           - ../shell/common-variables.sh
1359           - ../shell/maven-sonar.sh
1360       - lf-provide-maven-settings-cleanup
1361
1362 - job-template:
1363     name: "{project-name}-sonar"
1364     id: gerrit-maven-sonar
1365     <<: *lf_maven_common
1366     # yamllint disable-line rule:key-duplicates
1367     <<: *lf_maven_sonar
1368     <<: *mvn_sonar_builders
1369
1370     scm:
1371       - lf-infra-gerrit-scm:
1372           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1373           git-url: "{git-url}"
1374           refspec: $GERRIT_REFSPEC
1375           branch: $GERRIT_BRANCH
1376           submodule-recursive: "{submodule-recursive}"
1377           submodule-timeout: "{submodule-timeout}"
1378           submodule-disable: "{submodule-disable}"
1379           choosing-strategy: default
1380
1381 - job-template:
1382     name: "{project-name}-sonar-verify"
1383     id: gerrit-maven-sonar-verify
1384     <<: *lf_maven_common
1385     # yamllint disable-line rule:key-duplicates
1386     <<: *lf_maven_sonar
1387     <<: *mvn_sonar_builders
1388
1389     sonarcloud: true
1390     scan-dev-branch: true
1391     sonarcloud-qualitygate-wait: false
1392
1393     gerrit_sonar_triggers:
1394       - patchset-created-event:
1395           exclude-drafts: true
1396           exclude-trivial-rebase: false
1397           exclude-no-code-change: false
1398       - draft-published-event
1399       - comment-added-contains-event:
1400           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
1401
1402     gerrit_trigger_file_paths:
1403       - compare-type: REG_EXP
1404         pattern: ".*"
1405
1406     triggers:
1407       - gerrit:
1408           server-name: "{gerrit-server-name}"
1409           trigger-on: "{obj:gerrit_sonar_triggers}"
1410           projects:
1411             - project-compare-type: "ANT"
1412               project-pattern: "{project}"
1413               branches:
1414                 - branch-compare-type: "ANT"
1415                   branch-pattern: "**/{branch}"
1416               file-paths: "{obj:gerrit_trigger_file_paths}"
1417
1418     scm:
1419       - lf-infra-gerrit-scm:
1420           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1421           git-url: "{git-url}"
1422           refspec: $GERRIT_REFSPEC
1423           branch: $GERRIT_BRANCH
1424           submodule-recursive: "{submodule-recursive}"
1425           submodule-timeout: "{submodule-timeout}"
1426           submodule-disable: "{submodule-disable}"
1427           choosing-strategy: gerrit
1428
1429 - job-template:
1430     name: "{project-name}-sonar-prescan-script"
1431     id: gerrit-maven-sonar-prescan-script
1432     <<: *lf_maven_common
1433     # yamllint disable-line rule:key-duplicates
1434     <<: *lf_maven_sonar
1435     <<: *mvn_sonar_builders_prescan_script
1436
1437     scm:
1438       - lf-infra-gerrit-scm:
1439           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1440           git-url: "{git-url}"
1441           refspec: $GERRIT_REFSPEC
1442           branch: $GERRIT_BRANCH
1443           submodule-recursive: "{submodule-recursive}"
1444           submodule-timeout: "{submodule-timeout}"
1445           submodule-disable: "{submodule-disable}"
1446           choosing-strategy: default
1447
1448 - job-template:
1449     name: "{project-name}-sonar"
1450     id: github-maven-sonar
1451     <<: *lf_maven_common
1452     # yamllint disable-line rule:key-duplicates
1453     <<: *lf_maven_sonar
1454
1455     properties:
1456       - lf-infra-properties:
1457           build-days-to-keep: "{build-days-to-keep}"
1458       - github:
1459           url: "{github-url}/{github-org}/{project}"
1460
1461     scm:
1462       - lf-infra-github-scm:
1463           url: "{git-clone-url}{github-org}/{project}"
1464           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1465           branch: "$sha1"
1466           submodule-recursive: "{submodule-recursive}"
1467           submodule-timeout: "{submodule-timeout}"
1468           submodule-disable: "{submodule-disable}"
1469           choosing-strategy: default
1470           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1471
1472     triggers:
1473       - timed: "{obj:cron}"
1474       - github-pull-request:
1475           trigger-phrase: "^run-sonar$"
1476           only-trigger-phrase: true
1477           status-context: "Maven Sonar"
1478           permit-all: true
1479           github-hooks: true
1480           org-list:
1481             - "{github-org}"
1482           white-list: "{obj:github_pr_allowlist}"
1483           admin-list: "{obj:github_pr_admin_list}"
1484           white-list-target-branches:
1485             - "{branch}"
1486
1487 - job-template:
1488     name: "{project-name}-sonar-prescan-script"
1489     id: github-maven-sonar-prescan-script
1490     <<: *lf_maven_common
1491     # yamllint disable-line rule:key-duplicates
1492     <<: *lf_maven_sonar
1493     <<: *mvn_sonar_builders_prescan_script
1494
1495     properties:
1496       - lf-infra-properties:
1497           build-days-to-keep: "{build-days-to-keep}"
1498       - github:
1499           url: "{github-url}/{github-org}/{project}"
1500
1501     scm:
1502       - lf-infra-github-scm:
1503           url: "{git-clone-url}{github-org}/{project}"
1504           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1505           branch: "$sha1"
1506           submodule-recursive: "{submodule-recursive}"
1507           submodule-timeout: "{submodule-timeout}"
1508           submodule-disable: "{submodule-disable}"
1509           choosing-strategy: default
1510           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1511
1512     triggers:
1513       - timed: "{obj:cron}"
1514       - github-pull-request:
1515           trigger-phrase: "^run-sonar$"
1516           only-trigger-phrase: true
1517           status-context: "Maven Sonar"
1518           permit-all: true
1519           github-hooks: true
1520           org-list:
1521             - "{github-org}"
1522           white-list: "{obj:github_pr_allowlist}"
1523           admin-list: "{obj:github_pr_admin_list}"
1524           white-list-target-branches:
1525             - "{branch}"
1526
1527 ################
1528 # Maven Verify #
1529 ################
1530
1531 - lf_maven_verify: &lf_maven_verify
1532     name: lf-maven-verify
1533
1534     ######################
1535     # Default parameters #
1536     ######################
1537
1538     branch: master
1539     build-days-to-keep: 7
1540     build-timeout: 60
1541     disable-job: false
1542     git-url: "$GIT_URL/$PROJECT"
1543     github-url: "https://github.com"
1544     java-version: openjdk11
1545     mvn-global-settings: global-settings
1546     mvn-goals: clean deploy
1547     mvn-opts: ""
1548     mvn-params: "-Dstream=$STREAM -Dmaven.source.skip=true"
1549     mvn-version: mvn35
1550     pre-build-script: "# pre-build script goes here"
1551     post-build-script: "# post-build script goes here"
1552     stream: master
1553     submodule-recursive: true
1554     submodule-timeout: 10
1555     submodule-disable: false
1556
1557     gerrit_verify_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     # github_included_regions MUST match gerrit_trigger_file_paths
1571     github_included_regions:
1572       - ".*"
1573
1574     #####################
1575     # Job Configuration #
1576     #####################
1577
1578     concurrent: true
1579     disabled: "{disable-job}"
1580
1581     builders:
1582       - lf-infra-pre-build
1583       - lf-jacoco-nojava-workaround
1584       - lf-maven-install:
1585           mvn-version: "{mvn-version}"
1586       - lf-update-java-alternatives:
1587           java-version: "{java-version}"
1588       - lf-provide-maven-settings:
1589           global-settings-file: "{mvn-global-settings}"
1590           settings-file: "{mvn-settings}"
1591       - shell: "{pre-build-script}"
1592       - lf-maven-build:
1593           mvn-goals: "{mvn-goals}"
1594       - shell: "{post-build-script}"
1595       - lf-provide-maven-settings-cleanup
1596
1597     publishers:
1598       - findbugs
1599       - lf-jacoco-report
1600       - lf-infra-publish
1601
1602 - job-template:
1603     name: "{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}"
1604     id: gerrit-maven-verify
1605     <<: *lf_maven_common
1606     # yamllint disable-line rule:key-duplicates
1607     <<: *lf_maven_verify
1608
1609     scm:
1610       - lf-infra-gerrit-scm:
1611           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1612           git-url: "{git-url}"
1613           refspec: "$GERRIT_REFSPEC"
1614           branch: "$GERRIT_BRANCH"
1615           submodule-recursive: "{submodule-recursive}"
1616           submodule-timeout: "{submodule-timeout}"
1617           submodule-disable: "{submodule-disable}"
1618           choosing-strategy: gerrit
1619
1620     triggers:
1621       - gerrit:
1622           server-name: "{gerrit-server-name}"
1623           trigger-on: "{obj:gerrit_verify_triggers}"
1624           projects:
1625             - project-compare-type: ANT
1626               project-pattern: "{project}"
1627               branches:
1628                 - branch-compare-type: ANT
1629                   branch-pattern: "**/{branch}"
1630               file-paths: "{obj:gerrit_trigger_file_paths}"
1631
1632 - job-template:
1633     name: "{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}"
1634     id: github-maven-verify
1635     <<: *lf_maven_common
1636     # yamllint disable-line rule:key-duplicates
1637     <<: *lf_maven_verify
1638
1639     properties:
1640       - lf-infra-properties:
1641           build-days-to-keep: "{build-days-to-keep}"
1642       - github:
1643           url: "{github-url}/{github-org}/{project}"
1644
1645     scm:
1646       - lf-infra-github-scm:
1647           url: "{git-clone-url}{github-org}/{project}"
1648           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1649           branch: "$sha1"
1650           submodule-recursive: "{submodule-recursive}"
1651           submodule-timeout: "{submodule-timeout}"
1652           submodule-disable: "{submodule-disable}"
1653           choosing-strategy: default
1654           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1655
1656     triggers:
1657       - github-pull-request:
1658           trigger-phrase: "^(recheck|reverify)$"
1659           only-trigger-phrase: false
1660           status-context: "Maven Verify {mvn-version}-{java-version}"
1661           permit-all: true
1662           github-hooks: true
1663           white-list-target-branches:
1664             - "{branch}"
1665           included-regions: "{obj:github_included_regions}"
1666
1667 ###########################
1668 # Maven Verify for Docker #
1669 ###########################
1670
1671 - lf_maven_docker_verify: &lf_maven_docker_verify
1672     name: lf-maven-docker-verify
1673
1674     # image push not allowed during verification
1675     mvn-goals: clean install
1676
1677     builders:
1678       - lf-infra-pre-build
1679       - lf-jacoco-nojava-workaround
1680       - lf-maven-install:
1681           mvn-version: "{mvn-version}"
1682       - lf-update-java-alternatives:
1683           java-version: "{java-version}"
1684       - lf-infra-docker-login:
1685           global-settings-file: "{mvn-global-settings}"
1686           settings-file: "{mvn-settings}"
1687       # must provide maven settings AFTER docker due to its cleanup
1688       - lf-provide-maven-settings:
1689           global-settings-file: "{mvn-global-settings}"
1690           settings-file: "{mvn-settings}"
1691       - inject:
1692           properties-content: |
1693             CONTAINER_PULL_REGISTRY={container-public-registry}
1694       - lf-maven-build:
1695           mvn-goals: "{mvn-goals}"
1696       - lf-provide-maven-settings-cleanup
1697
1698 - job-template:
1699     name: "{project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}"
1700     id: gerrit-maven-docker-verify
1701     <<: *lf_maven_common
1702     # yamllint disable-line rule:key-duplicates
1703     <<: *lf_maven_verify
1704     # yamllint disable-line rule:key-duplicates
1705     <<: *lf_maven_docker_verify
1706
1707     scm:
1708       - lf-infra-gerrit-scm:
1709           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1710           git-url: "{git-url}"
1711           refspec: "$GERRIT_REFSPEC"
1712           branch: "$GERRIT_BRANCH"
1713           submodule-recursive: "{submodule-recursive}"
1714           submodule-timeout: "{submodule-timeout}"
1715           submodule-disable: "{submodule-disable}"
1716           choosing-strategy: gerrit
1717
1718     triggers:
1719       - gerrit:
1720           server-name: "{gerrit-server-name}"
1721           trigger-on: "{obj:gerrit_verify_triggers}"
1722           projects:
1723             - project-compare-type: ANT
1724               project-pattern: "{project}"
1725               branches:
1726                 - branch-compare-type: ANT
1727                   branch-pattern: "**/{branch}"
1728               file-paths: "{obj:gerrit_trigger_file_paths}"
1729
1730 - job-template:
1731     name: "{project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}"
1732     id: github-maven-docker-verify
1733     <<: *lf_maven_common
1734     # yamllint disable-line rule:key-duplicates
1735     <<: *lf_maven_verify
1736     # yamllint disable-line rule:key-duplicates
1737     <<: *lf_maven_docker_verify
1738
1739     properties:
1740       - lf-infra-properties:
1741           build-days-to-keep: "{build-days-to-keep}"
1742       - github:
1743           url: "{github-url}/{github-org}/{project}"
1744
1745     scm:
1746       - lf-infra-github-scm:
1747           url: "{git-clone-url}{github-org}/{project}"
1748           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
1749           branch: "$sha1"
1750           submodule-recursive: "{submodule-recursive}"
1751           submodule-timeout: "{submodule-timeout}"
1752           submodule-disable: "{submodule-disable}"
1753           choosing-strategy: default
1754           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1755
1756     triggers:
1757       - github-pull-request:
1758           trigger-phrase: "^(recheck|reverify)$"
1759           only-trigger-phrase: false
1760           status-context: "Maven Docker Verify {mvn-version}-{java-version}"
1761           permit-all: true
1762           github-hooks: true
1763           white-list-target-branches:
1764             - "{branch}"
1765           included-regions: "{obj:github_included_regions}"
1766
1767 #############################
1768 # Maven Verify Dependencies #
1769 #############################
1770
1771 - lf_maven_verify_dependencies: &lf_maven_verify_dependencies
1772     name: lf-maven-verify-dependencies
1773
1774     ######################
1775     # Default parameters #
1776     ######################
1777
1778     branch: master
1779     build-days-to-keep: 7
1780     build-timeout: 60
1781     disable-job: false
1782     git-url: "$GIT_URL/$PROJECT"
1783     github-url: "https://github.com"
1784     java-version: openjdk11
1785     mvn-global-settings: global-settings
1786     mvn-goals: clean deploy
1787     mvn-opts: ""
1788     mvn-params: "-Dstream=$STREAM"
1789     mvn-version: mvn35
1790     stream: master
1791     submodule-recursive: true
1792     submodule-timeout: 10
1793     submodule-disable: false
1794
1795     gerrit_verify_triggers:
1796       - comment-added-contains-event:
1797           comment-contains-value: "recheck: [0-9 ]+"
1798     gerrit_trigger_file_paths:
1799       - compare-type: ANT
1800         pattern: "**"
1801
1802     #####################
1803     # Job Configuration #
1804     #####################
1805
1806     concurrent: true
1807     disabled: "{disable-job}"
1808
1809     builders:
1810       - lf-infra-pre-build
1811       - lf-jacoco-nojava-workaround
1812       - lf-maven-install:
1813           mvn-version: "{mvn-version}"
1814       - lf-update-java-alternatives:
1815           java-version: "{java-version}"
1816       - lf-provide-maven-settings:
1817           global-settings-file: "{mvn-global-settings}"
1818           settings-file: "{mvn-settings}"
1819       - lf-fetch-dependent-patches
1820       - shell: !include-raw-escape:
1821           - ../shell/common-variables.sh
1822           - ../shell/maven-build-deps.sh
1823       - lf-maven-build:
1824           mvn-goals: "{mvn-goals}"
1825       - lf-provide-maven-settings-cleanup
1826
1827     publishers:
1828       - findbugs
1829       - lf-jacoco-report
1830       - lf-infra-publish
1831
1832 - job-template:
1833     name: "{project-name}-maven-verify-deps-{stream}-{mvn-version}-{java-version}"
1834     id: gerrit-maven-verify-dependencies
1835     <<: *lf_maven_common
1836     # yamllint disable-line rule:key-duplicates
1837     <<: *lf_maven_verify_dependencies
1838
1839     scm:
1840       - lf-infra-gerrit-scm:
1841           jenkins-ssh-credential: "{jenkins-ssh-credential}"
1842           git-url: "{git-url}"
1843           refspec: "$GERRIT_REFSPEC"
1844           branch: "$GERRIT_BRANCH"
1845           submodule-recursive: "{submodule-recursive}"
1846           submodule-timeout: "{submodule-timeout}"
1847           submodule-disable: "{submodule-disable}"
1848           choosing-strategy: gerrit
1849
1850     triggers:
1851       - gerrit:
1852           server-name: "{gerrit-server-name}"
1853           trigger-on: "{obj:gerrit_verify_triggers}"
1854           projects:
1855             - project-compare-type: ANT
1856               project-pattern: "{project}"
1857               branches:
1858                 - branch-compare-type: ANT
1859                   branch-pattern: "**/{branch}"
1860               file-paths: "{obj:gerrit_trigger_file_paths}"
1861           comment-text-parameter-mode: PLAIN