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