fc203e79f84b2d5e7519557b19f1dddb9dcd28c5
[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     #     :cron: Cron schedule when to trigger the job. This parameter also
188     #         supports multiline input via YAML pipe | character in cases where
189     #         one may want to provide more than 1 cron timer. (default: '')
190
191     ######################
192     # Default parameters #
193     ######################
194
195     branch: master
196     build-days-to-keep: 30  # 30 days in case a release takes long to get approved.
197     build-timeout: 30
198     git-url: '$GIT_URL/$PROJECT'
199     java-version: openjdk8
200     mvn-global-settings: global-settings
201     mvn-opts: ''
202     mvn-params: ''
203     mvn-version: mvn33
204     stream: master
205     submodule-recursive: true
206     cron: ''
207
208     gerrit_release_triggers:
209       - comment-added-contains-event:
210           comment-contains-value: build release$
211
212     #####################
213     # Job Configuration #
214     #####################
215
216     builders:
217       - lf-jacoco-nojava-workaround
218       - lf-maven-install:
219           mvn-version: '{mvn-version}'
220       - lf-provide-maven-settings:
221           global-settings-file: '{mvn-global-settings}'
222           settings-file: '{mvn-settings}'
223       - lf-infra-create-netrc:
224           server-id: opendaylight-staging
225       - shell: !include-raw-escape:
226           - ../shell/lftools-install.sh
227           - ../shell/common-variables.sh
228           - ../shell/maven-patch-release.sh
229           - ../shell/maven-build.sh
230           - ../shell/maven-stage.sh
231       - lf-provide-maven-settings-cleanup
232
233 - job-template:
234     name: '{project-name}-maven-release-{stream}'
235     id: gerrit-maven-release
236     <<: *lf_maven_common
237     # yamllint disable-line rule:key-duplicates
238     <<: *lf_maven_release
239
240     scm:
241       - lf-infra-gerrit-scm:
242           jenkins-ssh-credential: '{jenkins-ssh-credential}'
243           git-url: '{git-url}'
244           refspec: '$GERRIT_REFSPEC'
245           branch: '$GERRIT_BRANCH'
246           submodule-recursive: '{submodule-recursive}'
247           choosing-strategy: default
248
249     triggers:
250       - timed: '{obj:cron}'
251       - gerrit:
252           server-name: '{gerrit-server-name}'
253           trigger-on: '{obj:gerrit_release_triggers}'
254           projects:
255             - project-compare-type: ANT
256               project-pattern: '{project}'
257               branches:
258                 - branch-compare-type: ANT
259                   branch-pattern: '**/{branch}'
260
261 - job-template:
262     name: '{project-name}-maven-release-{stream}'
263     id: github-maven-release
264     <<: *lf_maven_common
265     # yamllint disable-line rule:key-duplicates
266     <<: *lf_maven_release
267
268     properties:
269       - github:
270           url: '{git-url}/{github-org}/{project}'
271
272     scm:
273       - lf-infra-github-scm:
274           url: '{git-clone-url}{github-org}/{project}'
275           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
276           branch: '{branch}'
277           submodule-recursive: '{submodule-recursive}'
278           choosing-strategy: default
279           jenkins-ssh-credential: '{jenkins-ssh-credential}'
280
281     triggers:
282       - timed: '{obj:cron}'
283       - lf-infra-github-pr-trigger:
284           trigger-phrase: '^build release$'
285           only-trigger-phrase: true
286           status-context: 'Maven Release'
287           permit-all: true
288           github-hooks: true
289           github-org: ''
290           github_pr_whitelist:
291             - ''
292           github_pr_admin_list:
293             - ''
294
295 ###############
296 # Maven Sonar #
297 ###############
298
299 - lf_maven_sonar: &lf_maven_sonar
300     name: lf-maven-sonar
301
302     # Sonar job which runs mvn clean install then publishes to Sonar.
303     #
304     # This job purposely only runs on the master branch as there are Additional
305     # configuration needed to support multiple branches and there's not much
306     # interest in that kind of support.
307     #
308     # Required parameters:
309     #
310     #     :build-node: The node to run build on.
311     #     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
312     #         be configured in defaults.yaml)
313     #     :mvn-settings: The name of settings file containing credentials for
314     #         the project.
315     #
316     # Optional parameters:
317     #
318     #     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
319     #     :build-timeout: Timeout in seconds before aborting build. (default: 60)
320     #     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
321     #     :java-version: Version of Java to use for the build. (default: openjdk8)
322     #     :mvn-global-settings: The name of the Maven global settings to use for
323     #         Maven configuration. (default: global-settings)
324     #     :mvn-opts: Sets MAVEN_OPTS. (default: '')
325     #     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
326     #     :mvn-version: Version of maven to use. (default: mvn33)
327     #     :submodule-recursive: Whether to checkout submodules recursively.
328     #         (default: true)
329     #
330     #     :gerrit_sonar_triggers: Override Gerrit Triggers.
331
332     ######################
333     # Default parameters #
334     ######################
335
336     branch: master  # Sonar should always be run on master branch
337     build-days-to-keep: 7
338     build-timeout: 30
339     git-url: '$GIT_URL/$PROJECT'
340     java-version: openjdk8
341     mvn-global-settings: global-settings
342     mvn-opts: ''
343     mvn-params: ''
344     mvn-version: mvn33
345     stream: master
346     submodule-recursive: true
347
348     gerrit_sonar_triggers:
349       - comment-added-contains-event:
350           comment-contains-value: run-sonar$
351
352     # Staging repos do not make sense for CLM jobs so set it blank.
353     staging-profile-id: ''
354
355     #####################
356     # Job Configuration #
357     #####################
358
359     triggers:
360       - timed: 'H H * * 6'
361       - gerrit:
362           server-name: '{gerrit-server-name}'
363           trigger-on: '{obj:gerrit_sonar_triggers}'
364           projects:
365             - project-compare-type: 'ANT'
366               project-pattern: '{project}'
367               branches:
368                 - branch-compare-type: 'ANT'
369                   branch-pattern: '**/master'
370           skip-vote:
371             successful: true
372             failed: true
373             unstable: true
374             notbuilt: true
375
376     builders:
377       - lf-infra-maven-sonar:
378           mvn-settings: '{mvn-settings}'
379           mvn-version: '{mvn-version}'
380
381     publishers:
382       - lf-jacoco-report
383       - findbugs
384       - lf-infra-publish
385
386 - builder:
387     name: lf-infra-maven-sonar
388     # Run a Sonar build with Maven
389     builders:
390       - lf-maven-install:
391           mvn-version: '{mvn-version}'
392       - inject:
393           # Switch this to the sonar wrapper when JJB 2.0 is available
394           properties-content: |
395               SONAR_HOST_URL=$SONAR_URL
396               SONAR_MAVEN_GOAL=sonar:sonar
397       - lf-provide-maven-settings:
398           global-settings-file: global-settings
399           settings-file: '{mvn-settings}'
400       - shell: !include-raw-escape:
401           - ../shell/common-variables.sh
402           - ../shell/maven-sonar.sh
403       - lf-provide-maven-settings-cleanup
404
405 - job-template:
406     name: '{project-name}-sonar'
407     id: gerrit-maven-sonar
408     <<: *lf_maven_common
409     # yamllint disable-line rule:key-duplicates
410     <<: *lf_maven_sonar
411
412     scm:
413       - lf-infra-gerrit-scm:
414           jenkins-ssh-credential: '{jenkins-ssh-credential}'
415           git-url: '{git-url}'
416           refspec: $GERRIT_REFSPEC
417           branch: $GERRIT_BRANCH
418           submodule-recursive: '{submodule-recursive}'
419           choosing-strategy: default
420
421 - job-template:
422     name: '{project-name}-sonar'
423     id: github-maven-sonar
424     <<: *lf_maven_common
425     # yamllint disable-line rule:key-duplicates
426     <<: *lf_maven_sonar
427
428     properties:
429       - github:
430           url: '{git-url}/{github-org}/{project}'
431
432     scm:
433       - lf-infra-github-scm:
434           url: '{git-clone-url}{github-org}/{project}'
435           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
436           branch: '{branch}'
437           submodule-recursive: '{submodule-recursive}'
438           choosing-strategy: default
439           jenkins-ssh-credential: '{jenkins-ssh-credential}'
440
441     triggers:
442       - lf-infra-github-pr-trigger:
443           trigger-phrase: '^recheck$'
444           only-trigger-phrase: false
445           status-context: 'Maven Verify'
446           permit-all: true
447           github-hooks: true
448           github-org: ''
449           github_pr_whitelist:
450             - ''
451           github_pr_admin_list:
452             - ''
453
454 ################
455 # Maven Verify #
456 ################
457
458 - lf_maven_verify: &lf_maven_verify
459     name: lf-maven-verify
460
461     # Verify job which runs mvn clean install to test a project build..
462     #
463     # Required parameters:
464     #
465     #     :build-node: The node to run build on.
466     #     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
467     #         be configured in defaults.yaml)
468     #     :mvn-settings: The name of settings file containing credentials for
469     #         the project.
470     #
471     # Optional parameters:
472     #
473     #     :branch: Git branch to fetch for the build. (default: master)
474     #     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
475     #     :build-timeout: Timeout in seconds before aborting build. (default: 60)
476     #     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
477     #     :java-version: Version of Java to use for the build. (default: openjdk8)
478     #     :mvn-global-settings: The name of the Maven global settings to use for
479     #         Maven configuration. (default: global-settings)
480     #     :mvn-opts: Sets MAVEN_OPTS. (default: '')
481     #     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
482     #     :mvn-version: Version of maven to use. (default: mvn33)
483     #     :stream: Keyword that can be used to represent a release code-name.
484     #         Often the same as the branch. (default: master)
485     #     :submodule-recursive: Whether to checkout submodules recursively.
486     #         (default: true)
487     #
488     #     :gerrit_verify_triggers: Override Gerrit Triggers.
489     #     :gerrit_trigger_file_paths: Override file paths which can be used to
490     #         filter which file modifications will trigger a build.
491
492     ######################
493     # Default parameters #
494     ######################
495
496     branch: master
497     build-days-to-keep: 7
498     build-timeout: 60
499     git-url: '$GIT_URL/$PROJECT'
500     java-version: openjdk8
501     mvn-global-settings: global-settings
502     mvn-opts: ''
503     mvn-params: '-Dstream=$STREAM'
504     mvn-version: mvn33
505     stream: master
506     submodule-recursive: true
507
508     gerrit_verify_triggers:
509       - patchset-created-event:
510           exclude-drafts: false
511           exclude-trivial-rebase: false
512           exclude-no-code-change: false
513       - draft-published-event
514       - comment-added-contains-event:
515           comment-contains-value: recheck$
516     gerrit_trigger_file_paths:
517       - compare-type: ANT
518         pattern: '**'
519
520     #####################
521     # Job Configuration #
522     #####################
523
524     concurrent: true
525
526     builders:
527       - lf-jacoco-nojava-workaround
528       - lf-maven-install:
529           mvn-version: '{mvn-version}'
530       - lf-provide-maven-settings:
531           global-settings-file: '{mvn-global-settings}'
532           settings-file: '{mvn-settings}'
533       - shell: !include-raw-escape:
534           - ../shell/lftools-install.sh
535           - ../shell/common-variables.sh
536           - ../shell/maven-build.sh
537       - lf-provide-maven-settings-cleanup
538
539     publishers:
540       - findbugs
541       - lf-jacoco-report
542       - lf-infra-publish
543
544 - job-template:
545     name: '{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}'
546     id: gerrit-maven-verify
547     <<: *lf_maven_common
548     # yamllint disable-line rule:key-duplicates
549     <<: *lf_maven_verify
550
551     scm:
552       - lf-infra-gerrit-scm:
553           jenkins-ssh-credential: '{jenkins-ssh-credential}'
554           git-url: '{git-url}'
555           refspec: '$GERRIT_REFSPEC'
556           branch: '$GERRIT_BRANCH'
557           submodule-recursive: '{submodule-recursive}'
558           choosing-strategy: gerrit
559
560     triggers:
561       - gerrit:
562           server-name: '{gerrit-server-name}'
563           trigger-on: '{obj:gerrit_verify_triggers}'
564           projects:
565             - project-compare-type: ANT
566               project-pattern: '{project}'
567               branches:
568                 - branch-compare-type: ANT
569                   branch-pattern: '**/{branch}'
570               file-paths: '{obj:gerrit_trigger_file_paths}'
571
572 - job-template:
573     name: '{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}'
574     id: github-maven-verify
575     <<: *lf_maven_common
576     # yamllint disable-line rule:key-duplicates
577     <<: *lf_maven_verify
578
579     properties:
580       - github:
581           url: '{git-url}/{github-org}/{project}'
582
583     scm:
584       - lf-infra-github-scm:
585           url: '{git-clone-url}{github-org}/{project}'
586           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
587           branch: '{branch}'
588           submodule-recursive: '{submodule-recursive}'
589           choosing-strategy: default
590           jenkins-ssh-credential: '{jenkins-ssh-credential}'
591
592     triggers:
593       - lf-infra-github-pr-trigger:
594           trigger-phrase: '^recheck$'
595           only-trigger-phrase: false
596           status-context: 'Maven Verify'
597           permit-all: true
598           github-hooks: true
599           github-org: ''
600           github_pr_whitelist:
601             - ''
602           github_pr_admin_list:
603             - ''