0238e9d6b87aac7f0e0f81548cfe0c85ccaf0626
[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       - lf-infra-maven-parameters:
47           mvn-opts: '{mvn-opts}'
48           mvn-params: '{mvn-params}'
49           mvn-version: '{mvn-version}'
50           # Staging repos do not make sense for CLM jobs so set it blank.
51           staging-profile-id: '{staging-profile-id}'
52
53     wrappers:
54       - lf-infra-wrappers:
55           build-timeout: '{build-timeout}'
56           jenkins-ssh-credential: '{jenkins-ssh-credential}'
57
58     publishers:
59       # TODO: Make email notification work.
60       # - lf-infra-email-notify:
61       #     email-recipients: '{email-recipients}'
62       #     email-prefix: '[releng]'
63       - lf-infra-publish
64
65 #############
66 # Maven CLM #
67 #############
68
69 - lf_maven_clm: &lf_maven_clm
70     name: lf-maven-clm
71
72     # Produces a CLM scan of the code into Nexus IQ Server.
73     #
74     # Required parameters:
75     #     build-node:    The node to run build on.
76     #     jenkins-ssh-credential: Credential to use for SSH. (Generally should
77     #                             be configured in defaults.yaml)
78     #     mvn-settings: The name of settings file containing credentials for
79     #                   the project.
80     #
81     # Optional parameters:
82     #     mvn-global-settings: The name of the Maven global settings to use for
83     #                          Maven configuration. (default: global-settings)
84
85     ######################
86     # Default parameters #
87     ######################
88
89     branch: master
90     build-days-to-keep: 30  # 30 days for troubleshooting purposes
91     build-timeout: 15
92     git-url: '$GIT_URL/$PROJECT'
93     java-version: openjdk8
94     mvn-global-settings: global-settings
95     mvn-opts: ''
96     mvn-params: ''
97     mvn-version: mvn33
98     stream: master
99     submodule-recursive: true
100
101     # Staging repos do not make sense for CLM jobs so set it blank.
102     staging-profile-id: ''
103
104     #####################
105     # Job Configuration #
106     #####################
107
108     triggers:
109       # Build weekly on Saturdays
110       - timed: 'H H * * 6'
111
112     builders:
113       - lf-maven-install:
114           mvn-version: '{mvn-version}'
115       - lf-provide-maven-settings:
116           global-settings-file: '{mvn-global-settings}'
117           settings-file: '{mvn-settings}'
118       - shell: !include-raw-escape:
119           - ../shell/common-variables.sh
120           - ../shell/sonatype-clm.sh
121       - lf-provide-maven-settings-cleanup
122       - shell: 'find . -regex ".*karaf/target" | xargs rm -rf'
123       - sonatype-clm:
124           application-name: '{project-name}'
125
126 - job-template:
127     name: '{project-name}-maven-clm-{stream}'
128     id: gerrit-maven-clm
129     <<: *lf_maven_common
130     # yamllint disable-line rule:key-duplicates
131     <<: *lf_maven_clm
132
133     scm:
134       - lf-infra-gerrit-scm:
135           jenkins-ssh-credential: '{jenkins-ssh-credential}'
136           git-url: '{git-url}'
137           refspec: '$GERRIT_REFSPEC'
138           branch: '$GERRIT_BRANCH'
139           submodule-recursive: '{submodule-recursive}'
140           choosing-strategy: default
141
142 - job-template:
143     name: '{project-name}-maven-clm-{stream}'
144     id: github-maven-clm
145     <<: *lf_maven_common
146     # yamllint disable-line rule:key-duplicates
147     <<: *lf_maven_clm
148
149     properties:
150       - github:
151           url: '{git-url}/{github-org}/{project}'
152
153     scm:
154       - lf-infra-github-scm:
155           url: '{git-clone-url}{github-org}/{project}'
156           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
157           branch: '{branch}'
158           submodule-recursive: '{submodule-recursive}'
159           choosing-strategy: default
160           jenkins-ssh-credential: '{jenkins-ssh-credential}'
161
162 #################
163 # Maven Release #
164 #################
165
166 - lf_maven_release: &lf_maven_release
167     name: lf-maven-release
168
169     # Produces a release candidate by creating a staging repo in Nexus.
170     #
171     # Runs a Maven build and deploys to $WORKSPACE/m2repo directory. This
172     # directory can then be reused later to deploy to Nexus.
173     #
174     # Required parameters:
175     #     build-node:    The node to run build on.
176     #     jenkins-ssh-credential: Credential to use for SSH. (Generally should
177     #                             be configured in defaults.yaml)
178     #     mvn-settings: The name of settings file containing credentials for
179     #                   the project.
180     #     staging-profile-id: Profile ID of the project's Nexus staging profile.
181     #
182     # Optional parameters:
183     #     mvn-global-settings: The name of the Maven global settings to use for
184     #                          Maven configuration. (default: global-settings)
185
186     ######################
187     # Default parameters #
188     ######################
189
190     branch: master
191     build-days-to-keep: 30  # 30 days in case a release takes long to get approved.
192     build-timeout: 30
193     git-url: '$GIT_URL/$PROJECT'
194     java-version: openjdk8
195     mvn-global-settings: global-settings
196     mvn-opts: ''
197     mvn-params: ''
198     mvn-version: mvn33
199     stream: master
200     submodule-recursive: true
201
202     #####################
203     # Job Configuration #
204     #####################
205
206     builders:
207       - lf-jacoco-nojava-workaround
208       - lf-maven-install:
209           mvn-version: '{mvn-version}'
210       - lf-provide-maven-settings:
211           global-settings-file: '{mvn-global-settings}'
212           settings-file: '{mvn-settings}'
213       - lf-infra-create-netrc:
214           server-id: opendaylight-staging
215       - shell: !include-raw-escape:
216           - ../shell/lftools-install.sh
217           - ../shell/common-variables.sh
218           - ../shell/maven-patch-release.sh
219           - ../shell/maven-build.sh
220           - ../shell/maven-stage.sh
221       - lf-provide-maven-settings-cleanup
222
223 - job-template:
224     name: '{project-name}-maven-release-{stream}'
225     id: gerrit-maven-release
226     <<: *lf_maven_common
227     # yamllint disable-line rule:key-duplicates
228     <<: *lf_maven_release
229
230     scm:
231       - lf-infra-gerrit-scm:
232           jenkins-ssh-credential: '{jenkins-ssh-credential}'
233           git-url: '{git-url}'
234           refspec: '$GERRIT_REFSPEC'
235           branch: '$GERRIT_BRANCH'
236           submodule-recursive: '{submodule-recursive}'
237           choosing-strategy: default
238
239 - job-template:
240     name: '{project-name}-maven-release-{stream}'
241     id: github-maven-release
242     <<: *lf_maven_common
243     # yamllint disable-line rule:key-duplicates
244     <<: *lf_maven_release
245
246     properties:
247       - github:
248           url: '{git-url}/{github-org}/{project}'
249
250     scm:
251       - lf-infra-github-scm:
252           url: '{git-clone-url}{github-org}/{project}'
253           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
254           branch: '{branch}'
255           submodule-recursive: '{submodule-recursive}'
256           choosing-strategy: default
257           jenkins-ssh-credential: '{jenkins-ssh-credential}'
258
259 ################
260 # Maven Verify #
261 ################
262
263 - lf_maven_verify: &lf_maven_verify
264     name: lf-maven-verify
265
266     # Verify job which runs mvn clean install to test a project build..
267     #
268     # Required parameters:
269     #
270     #     :build-node: The node to run build on.
271     #     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
272     #         be configured in defaults.yaml)
273     #     :mvn-settings: The name of settings file containing credentials for
274     #         the project.
275     #
276     # Optional parameters:
277     #
278     #     :branch: Git branch to fetch for the build. (default: master)
279     #     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
280     #     :build-timeout: Timeout in seconds before aborting build. (default: 60)
281     #     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
282     #     :java-version: Version of Java to use for the build. (default: openjdk8)
283     #     :mvn-global-settings: The name of the Maven global settings to use for
284     #         Maven configuration. (default: global-settings)
285     #     :mvn-opts: Sets MAVEN_OPTS. (default: '')
286     #     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
287     #     :mvn-version: Version of maven to use. (default: mvn33)
288     #     :stream: Keyword that can be used to represent a release code-name.
289     #         Often the same as the branch. (default: master)
290     #     :submodule-recursive: Whether to checkout submodules recursively.
291     #         (default: true)
292     #
293     #     :gerrit_verify_triggers: Override Gerrit Triggers.
294     #     :gerrit_trigger_file_paths: Override file paths which can be used to
295     #         filter which file modifications will trigger a build.
296
297     ######################
298     # Default parameters #
299     ######################
300
301     branch: master
302     build-days-to-keep: 7
303     build-timeout: 60
304     git-url: '$GIT_URL/$PROJECT'
305     java-version: openjdk8
306     mvn-global-settings: global-settings
307     mvn-opts: ''
308     mvn-params: '-Dstream=$STREAM'
309     mvn-version: mvn33
310     stream: master
311     submodule-recursive: true
312
313     gerrit_verify_triggers:
314       - patchset-created-event:
315           exclude-drafts: false
316           exclude-trivial-rebase: false
317           exclude-no-code-change: false
318       - draft-published-event
319       - comment-added-contains-event:
320           comment-contains-value: recheck$
321     gerrit_trigger_file_paths:
322       - compare-type: ANT
323         pattern: '**'
324
325     #####################
326     # Job Configuration #
327     #####################
328
329     concurrent: true
330
331     builders:
332       - lf-jacoco-nojava-workaround
333       - lf-maven-install:
334           mvn-version: '{mvn-version}'
335       - lf-provide-maven-settings:
336           global-settings-file: '{mvn-global-settings}'
337           settings-file: '{mvn-settings}'
338       - shell: !include-raw-escape:
339           - ../shell/lftools-install.sh
340           - ../shell/common-variables.sh
341           - ../shell/maven-build.sh
342       - lf-provide-maven-settings-cleanup
343
344     publishers:
345       - findbugs
346       - lf-jacoco-report
347       - lf-infra-publish
348
349 - job-template:
350     name: '{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}'
351     id: gerrit-maven-verify
352     <<: *lf_maven_common
353     # yamllint disable-line rule:key-duplicates
354     <<: *lf_maven_verify
355
356     scm:
357       - lf-infra-gerrit-scm:
358           jenkins-ssh-credential: '{jenkins-ssh-credential}'
359           git-url: '{git-url}'
360           refspec: '$GERRIT_REFSPEC'
361           branch: '$GERRIT_BRANCH'
362           submodule-recursive: '{submodule-recursive}'
363           choosing-strategy: gerrit
364
365     triggers:
366       - gerrit:
367           server-name: '{gerrit-server-name}'
368           trigger-on: '{obj:gerrit_verify_triggers}'
369           projects:
370             - project-compare-type: ANT
371               project-pattern: '{project}'
372               branches:
373                 - branch-compare-type: ANT
374                   branch-pattern: '**/{branch}'
375               file-paths: '{obj:gerrit_trigger_file_paths}'
376
377 - job-template:
378     name: '{project-name}-maven-verify-{stream}-{mvn-version}-{java-version}'
379     id: github-maven-verify
380     <<: *lf_maven_common
381     # yamllint disable-line rule:key-duplicates
382     <<: *lf_maven_verify
383
384     properties:
385       - github:
386           url: '{git-url}/{github-org}/{project}'
387
388     scm:
389       - lf-infra-github-scm:
390           url: '{git-clone-url}{github-org}/{project}'
391           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
392           branch: '{branch}'
393           submodule-recursive: '{submodule-recursive}'
394           choosing-strategy: default
395           jenkins-ssh-credential: '{jenkins-ssh-credential}'
396
397     triggers:
398       - lf-infra-github-pr-trigger:
399           trigger-phrase: '^recheck$'
400           only-trigger-phrase: false
401           status-context: 'Maven Verify'
402           permit-all: true
403           github-hooks: true
404           github-org: ''
405           github_pr_whitelist:
406             - ''
407           github_pr_admin_list:
408             - ''