60976693aaf5f57610d7b90cd0865f476ac07f1d
[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-infra-maven-sonarcloud
31 -------------------------
32
33 Runs Sonar against a Maven project and pushes results to SonarCloud.
34
35 :Required Parameters:
36
37     :java-version: Version of Java to execute Sonar with.
38     :mvn-version: Version of Maven to execute Sonar with.
39     :mvn-settings: Maven settings.xml file containing credentials to use.
40     :sonarcloud-project-key: SonarCloud project key.
41     :sonarcloud-project-organization: SonarCloud project organization.
42     :sonarcloud-api-token: SonarCloud API Token.
43
44 lf-maven-build
45 --------------
46
47 Calls the maven build script to perform a maven build.
48
49 :Required parameters:
50
51     :mvn-goals: The maven goals to perform for the build.
52         (default: clean deploy)
53
54 lf-maven-common
55 ---------------
56
57 Common Jenkins configuration for Maven jobs.
58
59 lf-maven-deploy
60 ---------------
61
62 Calls the maven deploy script to push artifacts to Nexus.
63
64 lf-maven-versions-plugin
65 ------------------------
66
67 Conditionally calls Maven versions plugin to set, update and commit the maven `versions:set`.
68
69 :Required Parameters:
70
71     :maven-versions-plugin: Whether to call Maven versions plugin or not. (default: false)
72     :mvn-version: Version of Maven to execute Sonar with.
73     :mvn-pom: Location of pom.xml.
74     :maven-versions-plugin-set-version: Version number to upgrade to.
75     :mvn-settings: Maven settings.xml file containing credentials to use.
76
77 lf-maven-stage
78 ---------------
79
80 Calls the maven stage script to push artifacts to a Nexus staging repository.
81
82 :Required Parameters:
83
84     :mvn-global-settings: The name of the Maven global settings to use for
85         Maven configuration.
86     :mvn-settings: The name of settings file containing credentials for the project.
87
88 lf-update-java-alternatives
89 ---------------------------
90
91 Setup Java alternatives for the Distro.
92
93 :Required Parameters:
94
95     :java-version: Version of Java to set as the default Java.
96         Eg. openjdk8
97
98 Job Templates
99 =============
100
101 Maven CLM
102 ---------
103
104 Produces a CLM scan of the code into Nexus IQ Server.
105
106 :Template Names:
107
108     - {project-name}-maven-clm-{stream}
109     - gerrit-maven-clm
110     - github-maven-clm
111
112 :Comment Trigger: run-clm
113
114 :Required parameters:
115
116     :build-node:    The node to run build on.
117     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
118         be configured in defaults.yaml)
119     :mvn-settings: The name of settings file containing credentials for the project.
120
121 :Optional parameters:
122
123     :branch: The branch to build against. (default: master)
124     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
125     :build-timeout: Timeout in minutes before aborting build. (default: 60)
126     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
127     :java-version: Version of Java to use for the build. (default: openjdk8)
128     :mvn-central: Set to 'true' to also stage to OSSRH. This is for projects
129         that want to release to Maven Central. If set the parameter
130         ``ossrh-profile-id`` also needs to be set. (default: false)
131     :mvn-global-settings: The name of the Maven global settings to use for
132         Maven configuration. (default: global-settings)
133     :mvn-opts: Sets MAVEN_OPTS. (default: '')
134     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
135     :mvn-version: Version of maven to use. (default: mvn35)
136     :nexus-iq-namespace: Insert a namespace to project AppID for projects that
137         share a Nexus IQ system to avoid project name collision. We recommend
138         inserting a trailing - dash if using this parameter.
139         For example 'odl-'. (default: '')
140     :nexus-iq-stage: Stage the policy evaluation will be run against on
141         the Nexus IQ Server. (default: 'build')
142     :ossrh-profile-id: Profile ID for project as provided by OSSRH.
143         (default: '')
144     :stream: Keyword that can be used to represent a release code-name.
145         Often the same as the branch. (default: master)
146     :submodule-recursive: Whether to checkout submodules recursively.
147         (default: true)
148     :submodule-timeout: Timeout (in minutes) for checkout operation.
149         (default: 10)
150
151     :gerrit_merge_triggers: Override Gerrit Triggers.
152
153 Maven JavaDoc Publish
154 ---------------------
155
156 Produces and publishes 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-publish-{stream}-{java-version}
163     - gerrit-maven-javadoc-publish
164     - github-maven-javadoc-publish
165
166 :Comment Trigger: remerge
167
168 :Required parameters:
169
170     :build-node: The node to run build on.
171     :javadoc-path: The path in Nexus to deploy javadoc to.
172     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
173         be configured in defaults.yaml)
174     :mvn-settings: The name of settings file containing credentials for the project.
175     :mvn-site-id: Maven Server ID from settings.xml to pull credentials from.
176         (Note: This setting should be configured in defaults.yaml.)
177
178 :Optional parameters:
179
180     :branch: The branch to build against. (default: master)
181     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
182     :build-timeout: Timeout in minutes before aborting build. (default: 60)
183     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
184     :java-version: Version of Java to use for the build. (default: openjdk8)
185     :mvn-global-settings: The name of the Maven global settings to use for
186         Maven configuration. (default: global-settings)
187     :mvn-opts: Sets MAVEN_OPTS. (default: '')
188     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
189     :mvn-version: Version of maven to use. (default: mvn35)
190     :stream: Keyword that can be used to represent a release code-name.
191         Often the same as the branch. (default: master)
192     :submodule-recursive: Whether to checkout submodules recursively.
193         (default: true)
194     :submodule-timeout: Timeout (in minutes) for checkout operation.
195         (default: 10)
196
197     :gerrit_merge_triggers: Override Gerrit Triggers.
198
199 Maven JavaDoc Verify
200 --------------------
201
202 Produces javadocs for a Maven project.
203
204 Expects javadocs to be available in $WORKSPACE/target/site/apidocs
205
206 :Template Names:
207
208     - {project-name}-maven-javadoc-verify-{stream}-{java-version}
209     - gerrit-maven-javadoc-verify
210     - github-maven-javadoc-verify
211
212 :Comment Trigger: recheck|reverify
213
214 :Required parameters:
215     :build-node:    The node to run build on.
216     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
217         be configured in defaults.yaml)
218     :mvn-settings: The name of settings file containing credentials for the project.
219
220 :Optional parameters:
221
222     :branch: The branch to build against. (default: master)
223     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
224     :build-timeout: Timeout in minutes before aborting build. (default: 60)
225     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
226     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
227     :java-version: Version of Java to use for the build. (default: openjdk8)
228     :mvn-global-settings: The name of the Maven global settings to use for
229         Maven configuration. (default: global-settings)
230     :mvn-opts: Sets MAVEN_OPTS. (default: '')
231     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
232     :mvn-version: Version of maven to use. (default: mvn35)
233     :stream: Keyword that can be used to represent a release code-name.
234         Often the same as the branch. (default: master)
235     :submodule-recursive: Whether to checkout submodules recursively.
236         (default: true)
237     :submodule-timeout: Timeout (in minutes) for checkout operation.
238         (default: 10)
239
240     :gerrit_verify_triggers: Override Gerrit Triggers.
241
242 Maven Merge
243 -----------
244
245 Merge job which runs `mvn clean deploy` to build a project.
246
247 This job pushes files to Nexus using cURL instead of allowing the Maven deploy
248 goal to push the upload. This is to get around the issue that Maven deploy does
249 not properly support uploading files at the end of the build and instead pushes
250 as it goes. There exists a `-Ddeploy-at-end` feature however it does not work
251 with extensions.
252
253 This job uses the following strategy to deploy jobs to Nexus:
254
255 1. `wget -r` to fetch maven-metadata.xml from Nexus
256 2. `mvn deploy -DaltDeploymentRepository` to prepare files for upload
257 3. Removes untouched maven-metadata.xml files before upload
258 4. Use lftools (cURL) upload script to push artifacts to Nexus
259
260 :Template Names:
261
262     - {project-name}-maven-merge-{stream}
263     - gerrit-maven-merge
264     - github-maven-merge
265
266 :Comment Trigger: remerge
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 the project.
274     :mvn-snapshot-id: Maven Server ID from settings.xml to pull credentials from.
275         (Note: This setting should be configured in defaults.yaml.)
276     :nexus-snapshot-repo: The repository id of the Nexus snapshot repo to deploy to.
277
278 :Optional parameters:
279
280     :branch: Git branch to fetch for the build. (default: master)
281     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
282     :build-timeout: Timeout in minutes before aborting build. (default: 60)
283     :cron: Cron schedule when to trigger the job. This parameter also
284         supports multiline input via YAML pipe | character in cases where
285         one may want to provide more than 1 cron timer. (default: 'H H * * 0'
286         to run weekly)
287     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
288     :java-version: Version of Java to use for the build. (default: openjdk8)
289     :mvn-global-settings: The name of the Maven global settings to use for
290         Maven configuration. (default: global-settings)
291     :mvn-opts: Sets MAVEN_OPTS. (default: '')
292     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
293     :mvn-version: Version of maven to use. (default: mvn35)
294     :nexus-cut-dirs: Number of directories to cut from file path for `wget -r`.
295     :stream: Keyword that can be used to represent a release code-name.
296         Often the same as the branch. (default: master)
297     :submodule-recursive: Whether to checkout submodules recursively.
298         (default: true)
299     :submodule-timeout: Timeout (in minutes) for checkout operation.
300         (default: 10)
301
302     :gerrit_merge_triggers: Override Gerrit Triggers.
303     :gerrit_trigger_file_paths: Override file paths which can be used to
304         filter which file modifications will trigger a build.
305
306 Maven Stage
307 -----------
308
309 Produces a release candidate by creating a staging repo in Nexus.
310
311 The staging repo name is in the format PROJECT-NUMBER for example "aaa-1234",
312 "autorelease-2000", "odlparent-1201", etc...
313
314 This job runs a Maven build and deploys to $WORKSPACE/m2repo directory. This
315 directory is then used later to deploy to Nexus.
316
317 :Template Names:
318
319     - {project-name}-maven-stage-{stream}
320     - gerrit-maven-stage
321     - github-maven-stage
322
323 :Required parameters:
324
325     :build-node: The node to run build on.
326     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
327         be configured in defaults.yaml)
328     :mvn-settings: The name of settings file containing credentials for the project.
329     :mvn-staging-id: Maven Server ID from settings.xml to pull credentials from.
330         (Note: This setting should be configured in defaults.yaml.)
331     :staging-profile-id: Profile ID of the project's Nexus staging profile.
332
333 :Optional parameters:
334
335     :archive-artifacts: Artifacts to archive to the logs server (default: '').
336     :branch: The branch to build against. (default: master)
337     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
338     :build-timeout: Timeout in minutes before aborting build. (default: 60)
339     :cron: Cron schedule when to trigger the job. This parameter also
340         supports multiline input via YAML pipe | character in cases where
341         one may want to provide more than 1 cron timer. (default: '')
342     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
343     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
344     :java-version: Version of Java to use for the build. (default: openjdk8)
345     :maven-versions-plugin: Whether to call Maven versions plugin or not. (default: false)
346     :mvn-global-settings: The name of the Maven global settings to use for
347         Maven configuration. (default: global-settings)
348     :mvn-opts: Sets MAVEN_OPTS. (default: '')
349     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
350     :mvn-version: Version of maven to use. (default: mvn35)
351     :maven-versions-plugin-set-version: New version to use in Maven versions plugin. (default: '')
352     :sign-artifacts: Sign artifacts with Sigul. (default: false)
353     :stream: Keyword that can be used to represent a release code-name.
354         Often the same as the branch. (default: master)
355     :submodule-recursive: Whether to checkout submodules recursively.
356         (default: true)
357     :submodule-timeout: Timeout (in minutes) for checkout operation.
358         (default: 10)
359
360     :gerrit_release_triggers: Override Gerrit Triggers.
361
362 .. _maven-sonar:
363
364 Maven Sonar
365 -----------
366
367 Sonar job which runs mvn clean install then publishes to Sonar.
368
369 This job purposely only runs on the master branch as there are Additional
370 configuration needed to support multiple branches and there's not much
371 interest in that kind of support.
372
373 :Template Names:
374
375     - {project-name}-sonar
376     - gerrit-maven-sonar
377     - github-maven-sonar
378
379 :Comment Trigger: run-sonar
380
381 :Required parameters:
382
383     :build-node: The node to run build on.
384     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
385         be configured in defaults.yaml)
386     :mvn-settings: The name of settings file containing credentials for the project.
387
388 :Optional parameters:
389
390     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
391     :build-timeout: Timeout in minutes before aborting build. (default: 60)
392     :cron: Cron schedule when to trigger the job. This parameter also
393         supports multiline input via YAML pipe | character in cases where
394         one may want to provide more than 1 cron timer.  (default: 'H H * * 6'
395         to run weekly)
396     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
397     :java-version: Version of Java to use for the build. (default: openjdk8)
398     :mvn-global-settings: The name of the Maven global settings to use for
399         Maven configuration. (default: global-settings)
400     :mvn-opts: Sets MAVEN_OPTS. (default: '')
401     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
402     :mvn-version: Version of maven to use. (default: mvn35)
403     :sonar-mvn-goals: Maven goals to run for sonar analysis.
404         (default: sonar:sonar)
405     :sonarcloud: Whether or not to use SonarCloud ``true|false``.
406         (default: false)
407     :sonarcloud-project-key: SonarCloud project key. (default: '')
408     :sonarcloud-project-organization: SonarCloud project organization.
409         (default: '')
410     :sonarcloud-api-token: SonarCloud API Token. (default: '')
411     :stream: Keyword that can be used to represent a release code-name.
412         Often the same as the branch. (default: master)
413     :submodule-recursive: Whether to checkout submodules recursively.
414         (default: true)
415     :submodule-timeout: Timeout (in minutes) for checkout operation.
416         (default: 10)
417
418     :gerrit_sonar_triggers: Override Gerrit Triggers.
419
420
421 SonarCloud Example:
422
423 .. literalinclude:: ../../.jjb-test/lf-maven-jobs/maven-sonarcloud.yaml
424    :language: yaml
425
426 Maven Verify
427 ------------
428
429 Verify job which runs mvn clean install to test a project build..
430
431 :Template Names:
432
433     - {project-name}-maven-verify-{stream}-{mvn-version}-{java-version}
434     - gerrit-maven-verify
435     - github-maven-verify
436
437 :Comment Trigger: recheck|reverify
438
439 :Required parameters:
440
441     :build-node: The node to run build on.
442     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
443         be configured in defaults.yaml)
444     :mvn-settings: The name of settings file containing credentials for the project.
445
446 :Optional parameters:
447
448     :branch: Git branch to fetch for the build. (default: master)
449     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
450     :build-timeout: Timeout in minutes before aborting build. (default: 60)
451     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
452     :java-version: Version of Java to use for the build. (default: openjdk8)
453     :mvn-global-settings: The name of the Maven global settings to use for
454         Maven configuration. (default: global-settings)
455     :mvn-opts: Sets MAVEN_OPTS. (default: '')
456     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
457     :mvn-version: Version of maven to use. (default: mvn35)
458     :stream: Keyword that can be used to represent a release code-name.
459         Often the same as the branch. (default: master)
460     :submodule-recursive: Whether to checkout submodules recursively.
461         (default: true)
462     :submodule-timeout: Timeout (in minutes) for checkout operation.
463         (default: 10)
464
465     :gerrit_verify_triggers: Override Gerrit Triggers.
466     :gerrit_trigger_file_paths: Override file paths which can be used to
467         filter which file modifications will trigger a build.
468
469 Maven Verify /w Dependencies
470 ----------------------------
471
472 Verify job which runs mvn clean install to test a project build /w deps
473
474 This job can be used to verify a patch in conjunction to all of the
475 upstream patches it depends on. The user of this job can provide a list
476 via comment trigger.
477
478 :Template Names:
479
480     - {project-name}-maven-verify-deps-{stream}-{mvn-version}-{java-version}
481     - gerrit-maven-verify-dependencies
482
483 :Comment Trigger: recheck: SPACE_SEPERATED_LIST_OF_PATCHES
484
485 :Required parameters:
486
487     :build-node: The node to run build on.
488     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
489         be configured in defaults.yaml)
490     :mvn-settings: The name of settings file containing credentials for the project.
491
492 :Optional parameters:
493
494     :branch: Git branch to fetch for the build. (default: master)
495     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
496     :build-timeout: Timeout in minutes before aborting build. (default: 60)
497     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
498     :java-version: Version of Java to use for the build. (default: openjdk8)
499     :mvn-global-settings: The name of the Maven global settings to use for
500         Maven configuration. (default: global-settings)
501     :mvn-opts: Sets MAVEN_OPTS. (default: '')
502     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
503     :mvn-version: Version of maven to use. (default: mvn35)
504     :stream: Keyword that can be used to represent a release code-name.
505         Often the same as the branch. (default: master)
506     :submodule-recursive: Whether to checkout submodules recursively.
507         (default: true)
508     :submodule-timeout: Timeout (in minutes) for checkout operation.
509         (default: 10)
510
511     :gerrit_verify_triggers: Override Gerrit Triggers.
512     :gerrit_trigger_file_paths: Override file paths which can be used to
513         filter which file modifications will trigger a build.