74a3e7ee4ab52e340e31ad47311325990293165d
[releng/global-jjb.git] / docs / jjb / lf-maven-jobs.rst
1 ##########
2 Maven Jobs
3 ##########
4
5 Job Groups
6 ==========
7
8 .. include:: ../job-groups.rst
9
10 Below is a list of Maven job groups:
11
12 .. literalinclude:: ../../jjb/lf-maven-job-groups.yaml
13    :language: yaml
14
15
16 Macros
17 ======
18
19 lf-infra-maven-sonar
20 --------------------
21
22 Runs Sonar against a Maven project.
23
24 :Required Parameters:
25
26     :java-version: Version of Java to execute Sonar with.
27     :mvn-version: Version of Maven to execute Sonar with.
28     :mvn-settings: Maven settings.xml file containing credentials to use.
29
30 lf-maven-build
31 --------------
32
33 Calls the maven build script to perform a maven build.
34
35 :Required parameters:
36
37     :mvn-goals: The maven goals to perform for the build.
38         (default: clean deploy)
39
40 lf-maven-common
41 ---------------
42
43 Common Jenkins configuration for Maven jobs.
44
45 lf-maven-deploy
46 ---------------
47
48 Calls the maven deploy script to push artifacts to Nexus.
49
50 lf-maven-stage
51 ---------------
52
53 Calls the maven stage script to push artifacts to a Nexus staging repository.
54
55 lf-update-java-alternatives
56 ---------------------------
57
58 Setup Java alternatives for the Distro.
59
60 :Required Parameters:
61
62     :java-version: Version of Java to set as the default Java.
63         Eg. openjdk8
64
65 Job Templates
66 =============
67
68 Maven CLM
69 ---------
70
71 Produces a CLM scan of the code into Nexus IQ Server.
72
73 :Template Names:
74
75     - {project-name}-maven-clm-{stream}
76     - gerrit-maven-clm
77     - github-maven-clm
78
79 :Comment Trigger: run-clm
80
81 :Required parameters:
82
83     :build-node:    The node to run build on.
84     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
85         be configured in defaults.yaml)
86     :mvn-settings: The name of settings file containing credentials for the project.
87
88 :Optional parameters:
89
90     :branch: The branch to build against. (default: master)
91     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
92     :build-timeout: Timeout in minutes before aborting build. (default: 60)
93     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
94     :java-version: Version of Java to use for the build. (default: openjdk8)
95     :mvn-global-settings: The name of the Maven global settings to use for
96         Maven configuration. (default: global-settings)
97     :mvn-opts: Sets MAVEN_OPTS. (default: '')
98     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
99     :mvn-version: Version of maven to use. (default: mvn35)
100     :nexus-iq-stage: Stage the policy evaluation will be run against on
101         the Nexus IQ Server. (default: 'build')
102     :stream: Keyword that can be used to represent a release code-name.
103         Often the same as the branch. (default: master)
104     :submodule-recursive: Whether to checkout submodules recursively.
105         (default: true)
106
107     :gerrit_merge_triggers: Override Gerrit Triggers.
108
109 Maven JavaDoc Publish
110 ---------------------
111
112 Produces and publishes javadocs for a Maven project.
113
114 Expects javadocs to be available in $WORKSPACE/target/site/apidocs
115
116 :Template Names:
117
118     - {project-name}-maven-javadoc-publish-{stream}
119     - gerrit-maven-javadoc-publish
120     - github-maven-javadoc-publish
121
122 :Comment Trigger: remerge
123
124 :Required parameters:
125
126     :build-node: The node to run build on.
127     :javadoc-path: The path in Nexus to deploy javadoc to.
128     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
129         be configured in defaults.yaml)
130     :mvn-settings: The name of settings file containing credentials for the project.
131     :mvn-site-id: Maven Server ID from settings.xml to pull credentials from.
132         (Note: This setting should be configured in defaults.yaml.)
133
134 :Optional parameters:
135
136     :branch: The branch to build against. (default: master)
137     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
138     :build-timeout: Timeout in minutes before aborting build. (default: 60)
139     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
140     :java-version: Version of Java to use for the build. (default: openjdk8)
141     :mvn-global-settings: The name of the Maven global settings to use for
142         Maven configuration. (default: global-settings)
143     :mvn-opts: Sets MAVEN_OPTS. (default: '')
144     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
145     :mvn-version: Version of maven to use. (default: mvn35)
146     :stream: Keyword that can be used to represent a release code-name.
147         Often the same as the branch. (default: master)
148     :submodule-recursive: Whether to checkout submodules recursively.
149         (default: true)
150
151     :gerrit_merge_triggers: Override Gerrit Triggers.
152
153 Maven JavaDoc Verify
154 --------------------
155
156 Produces javadocs for a Maven project.
157
158 Expects javadocs to be available in $WORKSPACE/target/site/apidocs
159
160 :Template Names:
161
162     - {project-name}-maven-javadoc-verify-{stream}
163     - gerrit-maven-javadoc-verify
164     - github-maven-javadoc-verify
165
166 :Comment Trigger: recheck|reverify
167
168 :Required parameters:
169     :build-node:    The node to run build on.
170     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
171         be configured in defaults.yaml)
172     :mvn-settings: The name of settings file containing credentials for the project.
173
174 :Optional parameters:
175
176     :branch: The branch to build against. (default: master)
177     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
178     :build-timeout: Timeout in minutes before aborting build. (default: 60)
179     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
180     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
181     :java-version: Version of Java to use for the build. (default: openjdk8)
182     :mvn-global-settings: The name of the Maven global settings to use for
183         Maven configuration. (default: global-settings)
184     :mvn-opts: Sets MAVEN_OPTS. (default: '')
185     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
186     :mvn-version: Version of maven to use. (default: mvn35)
187     :stream: Keyword that can be used to represent a release code-name.
188         Often the same as the branch. (default: master)
189     :submodule-recursive: Whether to checkout submodules recursively.
190         (default: true)
191
192     :gerrit_verify_triggers: Override Gerrit Triggers.
193
194 Maven Merge
195 -----------
196
197 Merge job which runs `mvn clean deploy` to build a project.
198
199 This job pushes files to Nexus using cURL instead of allowing the Maven deploy
200 goal to push the upload. This is to get around the issue that Maven deploy does
201 not properly support uploading files at the end of the build and instead pushes
202 as it goes. There exists a `-Ddeploy-at-end` feature however it does not work
203 with extensions.
204
205 This job uses the following strategy to deploy jobs to Nexus:
206
207 1. `wget -r` to fetch maven-metadata.xml from Nexus
208 2. `mvn deploy -DaltDeploymentRepository` to prepare files for upload
209 3. Removes untouched maven-metadata.xml files before upload
210 4. Use lftools (cURL) upload script to push artifacts to Nexus
211
212 :Template Names:
213
214     - {project-name}-maven-merge-{stream}
215     - gerrit-maven-merge
216     - github-maven-merge
217
218 :Comment Trigger: remerge
219
220 :Required parameters:
221
222     :build-node: The node to run build on.
223     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
224         be configured in defaults.yaml)
225     :mvn-settings: The name of settings file containing credentials for the project.
226     :mvn-snapshot-id: Maven Server ID from settings.xml to pull credentials from.
227         (Note: This setting should be configured in defaults.yaml.)
228     :nexus-snapshot-repo: The repository id of the Nexus snapshot repo to deploy to.
229
230 :Optional parameters:
231
232     :branch: Git branch to fetch for the build. (default: master)
233     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
234     :build-timeout: Timeout in minutes before aborting build. (default: 60)
235     :cron: Cron schedule when to trigger the job. This parameter also
236         supports multiline input via YAML pipe | character in cases where
237         one may want to provide more than 1 cron timer. (default: 'H H * * 0'
238         to run weekly)
239     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
240     :java-version: Version of Java to use for the build. (default: openjdk8)
241     :mvn-global-settings: The name of the Maven global settings to use for
242         Maven configuration. (default: global-settings)
243     :mvn-opts: Sets MAVEN_OPTS. (default: '')
244     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
245     :mvn-version: Version of maven to use. (default: mvn35)
246     :nexus-cut-dirs: Number of directories to cut from file path for `wget -r`.
247     :stream: Keyword that can be used to represent a release code-name.
248         Often the same as the branch. (default: master)
249     :submodule-recursive: Whether to checkout submodules recursively.
250         (default: true)
251
252     :gerrit_merge_triggers: Override Gerrit Triggers.
253     :gerrit_trigger_file_paths: Override file paths which can be used to
254         filter which file modifications will trigger a build.
255
256 Maven Stage
257 -----------
258
259 Produces a release candidate by creating a staging repo in Nexus.
260
261 The staging repo name is in the format PROJECT-NUMBER for example "aaa-1234",
262 "autorelease-2000", "odlparent-1201", etc...
263
264 This job runs a Maven build and deploys to $WORKSPACE/m2repo directory. This
265 directory is then used later to deploy to Nexus.
266
267 :Template Names:
268
269     - {project-name}-maven-stage-{stream}
270     - gerrit-maven-stage
271     - github-maven-stage
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 the project.
279     :mvn-staging-id: Maven Server ID from settings.xml to pull credentials from.
280         (Note: This setting should be configured in defaults.yaml.)
281     :staging-profile-id: Profile ID of the project's Nexus staging profile.
282
283 :Optional parameters:
284
285     :archive-artifacts: Artifacts to archive to the logs server (default: '').
286     :branch: The branch to build against. (default: master)
287     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
288     :build-timeout: Timeout in minutes before aborting build. (default: 60)
289     :cron: Cron schedule when to trigger the job. This parameter also
290         supports multiline input via YAML pipe | character in cases where
291         one may want to provide more than 1 cron timer. (default: '')
292     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
293     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
294     :java-version: Version of Java to use for the build. (default: openjdk8)
295     :mvn-global-settings: The name of the Maven global settings to use for
296         Maven configuration. (default: global-settings)
297     :mvn-opts: Sets MAVEN_OPTS. (default: '')
298     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
299     :mvn-version: Version of maven to use. (default: mvn35)
300     :stream: Keyword that can be used to represent a release code-name.
301         Often the same as the branch. (default: master)
302     :submodule-recursive: Whether to checkout submodules recursively.
303         (default: true)
304
305     :gerrit_release_triggers: Override Gerrit Triggers.
306
307 Maven Sonar
308 -----------
309
310 Sonar job which runs mvn clean install then publishes to Sonar.
311
312 This job purposely only runs on the master branch as there are Additional
313 configuration needed to support multiple branches and there's not much
314 interest in that kind of support.
315
316 :Template Names:
317
318     - {project-name}-sonar
319     - gerrit-maven-sonar
320     - github-maven-sonar
321
322 :Comment Trigger: run-sonar
323
324 :Required parameters:
325
326     :build-node: The node to run build on.
327     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
328         be configured in defaults.yaml)
329     :mvn-settings: The name of settings file containing credentials for the project.
330
331 :Optional parameters:
332
333     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
334     :build-timeout: Timeout in minutes before aborting build. (default: 60)
335     :cron: Cron schedule when to trigger the job. This parameter also
336         supports multiline input via YAML pipe | character in cases where
337         one may want to provide more than 1 cron timer.  (default: 'H H * * 6'
338         to run weekly)
339     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
340     :java-version: Version of Java to use for the build. (default: openjdk8)
341     :mvn-global-settings: The name of the Maven global settings to use for
342         Maven configuration. (default: global-settings)
343     :mvn-opts: Sets MAVEN_OPTS. (default: '')
344     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
345     :mvn-version: Version of maven to use. (default: mvn35)
346     :stream: Keyword that can be used to represent a release code-name.
347         Often the same as the branch. (default: master)
348     :submodule-recursive: Whether to checkout submodules recursively.
349         (default: true)
350
351     :gerrit_sonar_triggers: Override Gerrit Triggers.
352
353 Maven Verify
354 ------------
355
356 Verify job which runs mvn clean install to test a project build..
357
358 :Template Names:
359
360     - {project-name}-maven-verify-{stream}-{mvn-version}-{java-version}
361     - gerrit-maven-verify
362     - github-maven-verify
363
364 :Comment Trigger: recheck|reverify
365
366 :Required parameters:
367
368     :build-node: The node to run build on.
369     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
370         be configured in defaults.yaml)
371     :mvn-settings: The name of settings file containing credentials for the project.
372
373 :Optional parameters:
374
375     :branch: Git branch to fetch for the build. (default: master)
376     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
377     :build-timeout: Timeout in minutes before aborting build. (default: 60)
378     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
379     :java-version: Version of Java to use for the build. (default: openjdk8)
380     :mvn-global-settings: The name of the Maven global settings to use for
381         Maven configuration. (default: global-settings)
382     :mvn-opts: Sets MAVEN_OPTS. (default: '')
383     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
384     :mvn-version: Version of maven to use. (default: mvn35)
385     :stream: Keyword that can be used to represent a release code-name.
386         Often the same as the branch. (default: master)
387     :submodule-recursive: Whether to checkout submodules recursively.
388         (default: true)
389
390     :gerrit_verify_triggers: Override Gerrit Triggers.
391     :gerrit_trigger_file_paths: Override file paths which can be used to
392         filter which file modifications will trigger a build.
393
394 Maven Verify /w Dependencies
395 ----------------------------
396
397 Verify job which runs mvn clean install to test a project build /w deps
398
399 This job can be used to verify a patch in conjunction to all of the
400 upstream patches it depends on. The user of this job can provide a list
401 via comment trigger.
402
403 :Template Names:
404
405     - {project-name}-maven-verify-deps-{stream}-{mvn-version}-{java-version}
406     - gerrit-maven-verify-dependencies
407
408 :Comment Trigger: recheck: SPACE_SEPERATED_LIST_OF_PATCHES
409
410 :Required parameters:
411
412     :build-node: The node to run build on.
413     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
414         be configured in defaults.yaml)
415     :mvn-settings: The name of settings file containing credentials for the project.
416
417 :Optional parameters:
418
419     :branch: Git branch to fetch for the build. (default: master)
420     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
421     :build-timeout: Timeout in minutes before aborting build. (default: 60)
422     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
423     :java-version: Version of Java to use for the build. (default: openjdk8)
424     :mvn-global-settings: The name of the Maven global settings to use for
425         Maven configuration. (default: global-settings)
426     :mvn-opts: Sets MAVEN_OPTS. (default: '')
427     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
428     :mvn-version: Version of maven to use. (default: mvn35)
429     :stream: Keyword that can be used to represent a release code-name.
430         Often the same as the branch. (default: master)
431     :submodule-recursive: Whether to checkout submodules recursively.
432         (default: true)
433
434     :gerrit_verify_triggers: Override Gerrit Triggers.
435     :gerrit_trigger_file_paths: Override file paths which can be used to
436         filter which file modifications will trigger a build.