Merge "Migrate Maven Verify job template"
[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 Verify #
262 ################
263
264 - lf_maven_verify: &lf_maven_verify
265     name: lf-maven-verify
266
267     # Verify job which runs mvn clean install to test a project build..
268     #
269     # Required parameters:
270     #
271     #     :build-node: The node to run build on.
272     #     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
273     #         be configured in defaults.yaml)
274     #     :mvn-settings: The name of settings file containing credentials for
275     #         the project.
276     #
277     # Optional parameters:
278     #
279     #     :branch: Git branch to fetch for the build. (default: master)
280     #     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
281     #     :build-timeout: Timeout in seconds before aborting build. (default: 60)
282     #     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
283     #     :java-version: Version of Java to use for the build. (default: openjdk8)
284     #     :mvn-global-settings: The name of the Maven global settings to use for
285     #         Maven configuration. (default: global-settings)
286     #     :mvn-opts: Sets MAVEN_OPTS. (default: '')
287     #     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
288     #     :mvn-version: Version of maven to use. (default: mvn33)
289     #     :stream: Keyword that can be used to represent a release code-name.
290     #         Often the same as the branch. (default: master)
291     #     :submodule-recursive: Whether to checkout submodules recursively.
292     #         (default: true)
293     #
294     #     :gerrit_verify_triggers: Override Gerrit Triggers.
295     #     :gerrit_trigger_file_paths: Override file paths which can be used to
296     #         filter which file modifications will trigger a build.
297
298     ######################
299     # Default parameters #
300     ######################
301
302     branch: master
303     build-days-to-keep: 7
304     build-timeout: 60
305     git-url: '$GIT_URL/$PROJECT'
306     java-version: openjdk8
307     mvn-global-settings: global-settings
308     mvn-opts: ''
309     mvn-params: '-Dstream=$STREAM'
310     mvn-version: mvn33
311     stream: master
312     submodule-recursive: true
313
314     gerrit_verify_triggers:
315       - patchset-created-event:
316           exclude-drafts: false
317           exclude-trivial-rebase: false
318           exclude-no-code-change: false
319       - draft-published-event
320       - comment-added-contains-event:
321           comment-contains-value: recheck$
322     gerrit_trigger_file_paths:
323       - compare-type: ANT
324         pattern: '**'
325
326     #####################
327     # Job Configuration #
328     #####################
329
330     concurrent: true
331
332     builders:
333       - lf-jacoco-nojava-workaround
334       - lf-maven-install:
335           mvn-version: '{mvn-version}'
336       - lf-provide-maven-settings:
337           global-settings-file: '{mvn-global-settings}'
338           settings-file: '{mvn-settings}'
339       - shell: !include-raw-escape:
340           - ../shell/lftools-install.sh
341           - ../shell/common-variables.sh
342           - ../shell/maven-build.sh
343       - lf-provide-maven-settings-cleanup
344
345     publishers:
346       - findbugs
347       - lf-jacoco-report
348       - lf-infra-publish
349
350 - job-template:
351     name: '{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}'
352     id: gerrit-maven-verify
353     <<: *lf_maven_common
354     # yamllint disable-line rule:key-duplicates
355     <<: *lf_maven_verify
356
357     scm:
358       - lf-infra-gerrit-scm:
359           jenkins-ssh-credential: '{jenkins-ssh-credential}'
360           git-url: '{git-url}'
361           refspec: '$GERRIT_REFSPEC'
362           branch: '$GERRIT_BRANCH'
363           submodule-recursive: '{submodule-recursive}'
364           choosing-strategy: gerrit
365
366     triggers:
367       - gerrit:
368           server-name: '{gerrit-server-name}'
369           trigger-on: '{obj:gerrit_verify_triggers}'
370           projects:
371             - project-compare-type: ANT
372               project-pattern: '{project}'
373               branches:
374                 - branch-compare-type: ANT
375                   branch-pattern: '**/{branch}'
376               file-paths: '{obj:gerrit_trigger_file_paths}'
377
378 - job-template:
379     name: '{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}'
380     id: github-maven-verify
381     <<: *lf_maven_common
382     # yamllint disable-line rule:key-duplicates
383     <<: *lf_maven_verify
384
385     properties:
386       - github:
387           url: '{git-url}/{github-org}/{project}'
388
389     scm:
390       - lf-infra-github-scm:
391           url: '{git-clone-url}{github-org}/{project}'
392           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
393           branch: '{branch}'
394           submodule-recursive: '{submodule-recursive}'
395           choosing-strategy: default
396           jenkins-ssh-credential: '{jenkins-ssh-credential}'
397
398     triggers:
399       - lf-infra-github-pr-trigger:
400           trigger-phrase: '^recheck$'
401           only-trigger-phrase: false
402           status-context: 'Maven Verify'
403           permit-all: true
404           github-hooks: true
405           github-org: ''
406           github_pr_whitelist:
407             - ''
408           github_pr_admin_list:
409             - ''