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