1a689b342c57ae5aae58cdfa4e30838107244f93
[releng/global-jjb.git] / jjb / lf-maven-jobs.yaml
1 ---
2 # This file contains job templates for Maven projects.
3
4 - job-group:
5     name: '{project-name}-maven-jobs'
6
7     # This job group contains all the recommended jobs that should be deployed
8     # for any project ci.
9
10     jobs:
11       - gerrit-maven-clm
12       - gerrit-maven-release
13       - gerrit-maven-verify
14
15 - job-group:
16     name: '{project-name}-github-maven-jobs'
17
18     # This job group contains all the recommended jobs that should be deployed
19     # for any project ci that is using github.
20
21     jobs:
22       - github-maven-clm
23       - github-maven-release
24       - github-maven-verify
25
26 ####################
27 # COMMON FUNCTIONS #
28 ####################
29
30 - lf_maven_common: &lf_maven_common
31     name: lf-maven-common
32
33     project-type: freestyle
34     node: '{build-node}'
35     jdk: '{java-version}'
36
37     properties:
38       - lf-infra-properties:
39           build-days-to-keep: '{build-days-to-keep}'
40
41     parameters:
42       - lf-infra-parameters:
43           project: '{project}'
44           branch: '{branch}'
45           stream: '{stream}'
46           lftools-version: '{lftools-version}'
47       - lf-infra-maven-parameters:
48           mvn-opts: '{mvn-opts}'
49           mvn-params: '{mvn-params}'
50           mvn-version: '{mvn-version}'
51           # Staging repos do not make sense for CLM jobs so set it blank.
52           staging-profile-id: '{staging-profile-id}'
53
54     wrappers:
55       - lf-infra-wrappers:
56           build-timeout: '{build-timeout}'
57           jenkins-ssh-credential: '{jenkins-ssh-credential}'
58
59     publishers:
60       # TODO: Make email notification work.
61       # - lf-infra-email-notify:
62       #     email-recipients: '{email-recipients}'
63       #     email-prefix: '[releng]'
64       - lf-infra-publish
65
66 #############
67 # Maven CLM #
68 #############
69
70 - lf_maven_clm: &lf_maven_clm
71     name: lf-maven-clm
72
73     # Produces a CLM scan of the code into Nexus IQ Server.
74     #
75     # Required parameters:
76     #     build-node:    The node to run build on.
77     #     jenkins-ssh-credential: Credential to use for SSH. (Generally should
78     #                             be configured in defaults.yaml)
79     #     mvn-settings: The name of settings file containing credentials for
80     #                   the project.
81     #
82     # Optional parameters:
83     #     mvn-global-settings: The name of the Maven global settings to use for
84     #                          Maven configuration. (default: global-settings)
85
86     ######################
87     # Default parameters #
88     ######################
89
90     branch: master
91     build-days-to-keep: 30  # 30 days for troubleshooting purposes
92     build-timeout: 15
93     git-url: '$GIT_URL/$PROJECT'
94     java-version: openjdk8
95     mvn-global-settings: global-settings
96     mvn-opts: ''
97     mvn-params: ''
98     mvn-version: mvn33
99     stream: master
100     submodule-recursive: true
101
102     # Staging repos do not make sense for CLM jobs so set it blank.
103     staging-profile-id: ''
104
105     #####################
106     # Job Configuration #
107     #####################
108
109     triggers:
110       # Build weekly on Saturdays
111       - timed: 'H H * * 6'
112
113     builders:
114       - lf-maven-install:
115           mvn-version: '{mvn-version}'
116       - lf-provide-maven-settings:
117           global-settings-file: '{mvn-global-settings}'
118           settings-file: '{mvn-settings}'
119       - shell: !include-raw-escape:
120           - ../shell/common-variables.sh
121           - ../shell/sonatype-clm.sh
122       - lf-provide-maven-settings-cleanup
123       - shell: 'find . -regex ".*karaf/target" | xargs rm -rf'
124       - sonatype-clm:
125           application-name: '{project-name}'
126
127 - job-template:
128     name: '{project-name}-maven-clm-{stream}'
129     id: gerrit-maven-clm
130     <<: *lf_maven_common
131     # yamllint disable-line rule:key-duplicates
132     <<: *lf_maven_clm
133
134     scm:
135       - lf-infra-gerrit-scm:
136           jenkins-ssh-credential: '{jenkins-ssh-credential}'
137           git-url: '{git-url}'
138           refspec: '$GERRIT_REFSPEC'
139           branch: '$GERRIT_BRANCH'
140           submodule-recursive: '{submodule-recursive}'
141           choosing-strategy: default
142
143 - job-template:
144     name: '{project-name}-maven-clm-{stream}'
145     id: github-maven-clm
146     <<: *lf_maven_common
147     # yamllint disable-line rule:key-duplicates
148     <<: *lf_maven_clm
149
150     properties:
151       - github:
152           url: '{git-url}/{github-org}/{project}'
153
154     scm:
155       - lf-infra-github-scm:
156           url: '{git-clone-url}{github-org}/{project}'
157           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
158           branch: '{branch}'
159           submodule-recursive: '{submodule-recursive}'
160           choosing-strategy: default
161           jenkins-ssh-credential: '{jenkins-ssh-credential}'
162
163 #################
164 # Maven Release #
165 #################
166
167 - lf_maven_release: &lf_maven_release
168     name: lf-maven-release
169
170     # Produces a release candidate by creating a staging repo in Nexus.
171     #
172     # Runs a Maven build and deploys to $WORKSPACE/m2repo directory. This
173     # directory can then be reused later to deploy to Nexus.
174     #
175     # Required parameters:
176     #     build-node:    The node to run build on.
177     #     jenkins-ssh-credential: Credential to use for SSH. (Generally should
178     #                             be configured in defaults.yaml)
179     #     mvn-settings: The name of settings file containing credentials for
180     #                   the project.
181     #     staging-profile-id: Profile ID of the project's Nexus staging profile.
182     #
183     # Optional parameters:
184     #     :gerrit_verify_triggers: Override Gerrit Triggers.
185     #     :mvn-global-settings: The name of the Maven global settings to use for
186     #                           Maven configuration. (default: global-settings)
187
188     ######################
189     # Default parameters #
190     ######################
191
192     branch: master
193     build-days-to-keep: 30  # 30 days in case a release takes long to get approved.
194     build-timeout: 30
195     git-url: '$GIT_URL/$PROJECT'
196     java-version: openjdk8
197     mvn-global-settings: global-settings
198     mvn-opts: ''
199     mvn-params: ''
200     mvn-version: mvn33
201     stream: master
202     submodule-recursive: true
203
204     gerrit_release_triggers:
205       - comment-added-contains-event:
206           comment-contains-value: build release$
207
208     #####################
209     # Job Configuration #
210     #####################
211
212     builders:
213       - lf-jacoco-nojava-workaround
214       - lf-maven-install:
215           mvn-version: '{mvn-version}'
216       - lf-provide-maven-settings:
217           global-settings-file: '{mvn-global-settings}'
218           settings-file: '{mvn-settings}'
219       - lf-infra-create-netrc:
220           server-id: opendaylight-staging
221       - shell: !include-raw-escape:
222           - ../shell/lftools-install.sh
223           - ../shell/common-variables.sh
224           - ../shell/maven-patch-release.sh
225           - ../shell/maven-build.sh
226           - ../shell/maven-stage.sh
227       - lf-provide-maven-settings-cleanup
228
229 - job-template:
230     name: '{project-name}-maven-release-{stream}'
231     id: gerrit-maven-release
232     <<: *lf_maven_common
233     # yamllint disable-line rule:key-duplicates
234     <<: *lf_maven_release
235
236     scm:
237       - lf-infra-gerrit-scm:
238           jenkins-ssh-credential: '{jenkins-ssh-credential}'
239           git-url: '{git-url}'
240           refspec: '$GERRIT_REFSPEC'
241           branch: '$GERRIT_BRANCH'
242           submodule-recursive: '{submodule-recursive}'
243           choosing-strategy: default
244
245     triggers:
246       - gerrit:
247           server-name: '{gerrit-server-name}'
248           trigger-on: '{obj:gerrit_release_triggers}'
249           projects:
250             - project-compare-type: ANT
251               project-pattern: '{project}'
252               branches:
253                 - branch-compare-type: ANT
254                   branch-pattern: '**/{branch}'
255
256 - job-template:
257     name: '{project-name}-maven-release-{stream}'
258     id: github-maven-release
259     <<: *lf_maven_common
260     # yamllint disable-line rule:key-duplicates
261     <<: *lf_maven_release
262
263     properties:
264       - github:
265           url: '{git-url}/{github-org}/{project}'
266
267     scm:
268       - lf-infra-github-scm:
269           url: '{git-clone-url}{github-org}/{project}'
270           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
271           branch: '{branch}'
272           submodule-recursive: '{submodule-recursive}'
273           choosing-strategy: default
274           jenkins-ssh-credential: '{jenkins-ssh-credential}'
275
276     triggers:
277       - lf-infra-github-pr-trigger:
278           trigger-phrase: '^build release$'
279           only-trigger-phrase: true
280           status-context: 'Maven Release'
281           permit-all: true
282           github-hooks: true
283           github-org: ''
284           github_pr_whitelist:
285             - ''
286           github_pr_admin_list:
287             - ''
288
289 ###############
290 # Maven Sonar #
291 ###############
292
293 - lf_maven_sonar: &lf_maven_sonar
294     name: lf-maven-sonar
295
296     # Sonar job which runs mvn clean install then publishes to Sonar.
297     #
298     # This job purposely only runs on the master branch as there are Additional
299     # configuration needed to support multiple branches and there's not much
300     # interest in that kind of support.
301     #
302     # Required parameters:
303     #
304     #     :build-node: The node to run build on.
305     #     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
306     #         be configured in defaults.yaml)
307     #     :mvn-settings: The name of settings file containing credentials for
308     #         the project.
309     #
310     # Optional parameters:
311     #
312     #     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
313     #     :build-timeout: Timeout in seconds before aborting build. (default: 60)
314     #     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
315     #     :java-version: Version of Java to use for the build. (default: openjdk8)
316     #     :mvn-global-settings: The name of the Maven global settings to use for
317     #         Maven configuration. (default: global-settings)
318     #     :mvn-opts: Sets MAVEN_OPTS. (default: '')
319     #     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
320     #     :mvn-version: Version of maven to use. (default: mvn33)
321     #     :submodule-recursive: Whether to checkout submodules recursively.
322     #         (default: true)
323     #
324     #     :gerrit_sonar_triggers: Override Gerrit Triggers.
325
326     ######################
327     # Default parameters #
328     ######################
329
330     branch: master  # Sonar should always be run on master branch
331     build-days-to-keep: 7
332     build-timeout: 30
333     git-url: '$GIT_URL/$PROJECT'
334     java-version: openjdk8
335     mvn-global-settings: global-settings
336     mvn-opts: ''
337     mvn-params: ''
338     mvn-version: mvn33
339     stream: master
340     submodule-recursive: true
341
342     gerrit_sonar_triggers:
343       - comment-added-contains-event:
344           comment-contains-value: run-sonar$
345
346     # Staging repos do not make sense for CLM jobs so set it blank.
347     staging-profile-id: ''
348
349     #####################
350     # Job Configuration #
351     #####################
352
353     triggers:
354       - timed: 'H H * * 6'
355       - gerrit:
356           server-name: '{gerrit-server-name}'
357           trigger-on: '{obj:gerrit_sonar_triggers}'
358           projects:
359             - project-compare-type: 'ANT'
360               project-pattern: '{project}'
361               branches:
362                 - branch-compare-type: 'ANT'
363                   branch-pattern: '**/master'
364           skip-vote:
365             successful: true
366             failed: true
367             unstable: true
368             notbuilt: true
369
370     builders:
371       - lf-infra-maven-sonar:
372           mvn-settings: '{mvn-settings}'
373           mvn-version: '{mvn-version}'
374
375     publishers:
376       - lf-jacoco-report
377       - findbugs
378       - lf-infra-publish
379
380 - builder:
381     name: lf-infra-maven-sonar
382     # Run a Sonar build with Maven
383     builders:
384       - lf-maven-install:
385           mvn-version: '{mvn-version}'
386       - inject:
387           # Switch this to the sonar wrapper when JJB 2.0 is available
388           properties-content: |
389               SONAR_HOST_URL=$SONAR_URL
390               SONAR_MAVEN_GOAL=sonar:sonar
391       - lf-provide-maven-settings:
392           global-settings-file: global-settings
393           settings-file: '{mvn-settings}'
394       - shell: !include-raw-escape:
395           - ../shell/common-variables.sh
396           - ../shell/maven-sonar.sh
397       - lf-provide-maven-settings-cleanup
398
399 - job-template:
400     name: '{project-name}-sonar'
401     id: gerrit-maven-sonar
402     <<: *lf_maven_common
403     # yamllint disable-line rule:key-duplicates
404     <<: *lf_maven_sonar
405
406     scm:
407       - lf-infra-gerrit-scm:
408           jenkins-ssh-credential: '{jenkins-ssh-credential}'
409           git-url: '{git-url}'
410           refspec: $GERRIT_REFSPEC
411           branch: $GERRIT_BRANCH
412           submodule-recursive: '{submodule-recursive}'
413           choosing-strategy: default
414
415 - job-template:
416     name: '{project-name}-sonar'
417     id: github-maven-sonar
418     <<: *lf_maven_common
419     # yamllint disable-line rule:key-duplicates
420     <<: *lf_maven_sonar
421
422     properties:
423       - github:
424           url: '{git-url}/{github-org}/{project}'
425
426     scm:
427       - lf-infra-github-scm:
428           url: '{git-clone-url}{github-org}/{project}'
429           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
430           branch: '{branch}'
431           submodule-recursive: '{submodule-recursive}'
432           choosing-strategy: default
433           jenkins-ssh-credential: '{jenkins-ssh-credential}'
434
435     triggers:
436       - lf-infra-github-pr-trigger:
437           trigger-phrase: '^recheck$'
438           only-trigger-phrase: false
439           status-context: 'Maven Verify'
440           permit-all: true
441           github-hooks: true
442           github-org: ''
443           github_pr_whitelist:
444             - ''
445           github_pr_admin_list:
446             - ''
447
448 ################
449 # Maven Verify #
450 ################
451
452 - lf_maven_verify: &lf_maven_verify
453     name: lf-maven-verify
454
455     # Verify job which runs mvn clean install to test a project build..
456     #
457     # Required parameters:
458     #
459     #     :build-node: The node to run build on.
460     #     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
461     #         be configured in defaults.yaml)
462     #     :mvn-settings: The name of settings file containing credentials for
463     #         the project.
464     #
465     # Optional parameters:
466     #
467     #     :branch: Git branch to fetch for the build. (default: master)
468     #     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
469     #     :build-timeout: Timeout in seconds before aborting build. (default: 60)
470     #     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
471     #     :java-version: Version of Java to use for the build. (default: openjdk8)
472     #     :mvn-global-settings: The name of the Maven global settings to use for
473     #         Maven configuration. (default: global-settings)
474     #     :mvn-opts: Sets MAVEN_OPTS. (default: '')
475     #     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
476     #     :mvn-version: Version of maven to use. (default: mvn33)
477     #     :stream: Keyword that can be used to represent a release code-name.
478     #         Often the same as the branch. (default: master)
479     #     :submodule-recursive: Whether to checkout submodules recursively.
480     #         (default: true)
481     #
482     #     :gerrit_verify_triggers: Override Gerrit Triggers.
483     #     :gerrit_trigger_file_paths: Override file paths which can be used to
484     #         filter which file modifications will trigger a build.
485
486     ######################
487     # Default parameters #
488     ######################
489
490     branch: master
491     build-days-to-keep: 7
492     build-timeout: 60
493     git-url: '$GIT_URL/$PROJECT'
494     java-version: openjdk8
495     mvn-global-settings: global-settings
496     mvn-opts: ''
497     mvn-params: '-Dstream=$STREAM'
498     mvn-version: mvn33
499     stream: master
500     submodule-recursive: true
501
502     gerrit_verify_triggers:
503       - patchset-created-event:
504           exclude-drafts: false
505           exclude-trivial-rebase: false
506           exclude-no-code-change: false
507       - draft-published-event
508       - comment-added-contains-event:
509           comment-contains-value: recheck$
510     gerrit_trigger_file_paths:
511       - compare-type: ANT
512         pattern: '**'
513
514     #####################
515     # Job Configuration #
516     #####################
517
518     concurrent: true
519
520     builders:
521       - lf-jacoco-nojava-workaround
522       - lf-maven-install:
523           mvn-version: '{mvn-version}'
524       - lf-provide-maven-settings:
525           global-settings-file: '{mvn-global-settings}'
526           settings-file: '{mvn-settings}'
527       - shell: !include-raw-escape:
528           - ../shell/lftools-install.sh
529           - ../shell/common-variables.sh
530           - ../shell/maven-build.sh
531       - lf-provide-maven-settings-cleanup
532
533     publishers:
534       - findbugs
535       - lf-jacoco-report
536       - lf-infra-publish
537
538 - job-template:
539     name: '{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}'
540     id: gerrit-maven-verify
541     <<: *lf_maven_common
542     # yamllint disable-line rule:key-duplicates
543     <<: *lf_maven_verify
544
545     scm:
546       - lf-infra-gerrit-scm:
547           jenkins-ssh-credential: '{jenkins-ssh-credential}'
548           git-url: '{git-url}'
549           refspec: '$GERRIT_REFSPEC'
550           branch: '$GERRIT_BRANCH'
551           submodule-recursive: '{submodule-recursive}'
552           choosing-strategy: gerrit
553
554     triggers:
555       - gerrit:
556           server-name: '{gerrit-server-name}'
557           trigger-on: '{obj:gerrit_verify_triggers}'
558           projects:
559             - project-compare-type: ANT
560               project-pattern: '{project}'
561               branches:
562                 - branch-compare-type: ANT
563                   branch-pattern: '**/{branch}'
564               file-paths: '{obj:gerrit_trigger_file_paths}'
565
566 - job-template:
567     name: '{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}'
568     id: github-maven-verify
569     <<: *lf_maven_common
570     # yamllint disable-line rule:key-duplicates
571     <<: *lf_maven_verify
572
573     properties:
574       - github:
575           url: '{git-url}/{github-org}/{project}'
576
577     scm:
578       - lf-infra-github-scm:
579           url: '{git-clone-url}{github-org}/{project}'
580           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
581           branch: '{branch}'
582           submodule-recursive: '{submodule-recursive}'
583           choosing-strategy: default
584           jenkins-ssh-credential: '{jenkins-ssh-credential}'
585
586     triggers:
587       - lf-infra-github-pr-trigger:
588           trigger-phrase: '^recheck$'
589           only-trigger-phrase: false
590           status-context: 'Maven Verify'
591           permit-all: true
592           github-hooks: true
593           github-org: ''
594           github_pr_whitelist:
595             - ''
596           github_pr_admin_list:
597             - ''