Fix rtd merge job to handle new tag uploaded
[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     :version-properties-file: Name and path of the version properties file.
73         (default: version.properties)
74     :mvn-version: Version of Maven to execute Sonar with.
75     :mvn-pom: Location of pom.xml.
76     :mvn-settings: Maven settings.xml file containing credentials to use.
77
78 lf-maven-stage
79 --------------
80
81 Calls the maven stage script to push artifacts to a Nexus staging repository.
82
83 :Required Parameters:
84
85     :mvn-global-settings: The name of the Maven global settings to use for
86         Maven configuration.
87     :mvn-settings: The name of settings file containing credentials for the project.
88
89 lf-update-java-alternatives
90 ---------------------------
91
92 Setup Java alternatives for the Distro.
93
94 :Required Parameters:
95
96     :java-version: Version of Java to set as the default Java.
97         Eg. openjdk8
98
99 lf-infra-sonatype-clm
100 ---------------------
101
102 Runs a Sonatype CLM scan against a Maven project and pushes results to
103 Nexus IQ server.
104
105 :Optional parameters:
106     :mvn-goals: The maven goals to perform for the build.
107         (default: clean install)
108
109 Job Templates
110 =============
111
112 Maven CLM
113 ---------
114
115 Produces a CLM scan of the code into Nexus IQ Server.
116
117 :Template Names:
118
119     - {project-name}-maven-clm-{stream}
120     - gerrit-maven-clm
121     - github-maven-clm
122
123 :Comment Trigger: run-clm
124
125 :Required parameters:
126
127     :build-node:    The node to run build on.
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
132 :Optional parameters:
133
134     :branch: The branch to build against. (default: master)
135     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
136     :build-timeout: Timeout in minutes before aborting build. (default: 60)
137     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
138     :java-version: Version of Java to use for the build. (default: openjdk8)
139     :mvn-global-settings: The name of the Maven global settings to use for
140         Maven configuration. (default: global-settings)
141     :mvn-goals: The maven goals to perform for the build.
142         (default: clean install)
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     :nexus-iq-namespace: Insert a namespace to project AppID for projects that
147         share a Nexus IQ system to avoid project name collision. We recommend
148         inserting a trailing - dash if using this parameter.
149         For example 'odl-'. (default: '')
150     :nexus-iq-stage: Stage the policy evaluation will be run against on
151         the Nexus IQ Server. (default: 'build')
152     :stream: Keyword that can be used to represent a release code-name.
153         Often the same as the branch. (default: master)
154     :submodule-recursive: Whether to checkout submodules recursively.
155         (default: true)
156     :submodule-timeout: Timeout (in minutes) for checkout operation.
157         (default: 10)
158     :submodule-disable: Disable submodule checkout operation.
159         (default: false)
160
161     :gerrit_merge_triggers: Override Gerrit Triggers.
162
163 Maven JavaDoc Publish
164 ---------------------
165
166 Produces and publishes javadocs for a Maven project.
167
168 Expects javadocs to be available in $WORKSPACE/target/site/apidocs
169
170 :Template Names:
171
172     - {project-name}-maven-javadoc-publish-{stream}-{java-version}
173     - gerrit-maven-javadoc-publish
174     - github-maven-javadoc-publish
175
176 :Comment Trigger: remerge
177
178 :Required parameters:
179
180     :build-node: The node to run build on.
181     :javadoc-path: The path in Nexus to deploy javadoc to.
182     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
183         be configured in defaults.yaml)
184     :mvn-settings: The name of settings file containing credentials for the project.
185     :mvn-site-id: Maven Server ID from settings.xml to pull credentials from.
186         (Note: This setting should be configured in defaults.yaml.)
187
188 :Optional parameters:
189
190     :branch: The branch to build against. (default: master)
191     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
192     :build-timeout: Timeout in minutes before aborting build. (default: 60)
193     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
194     :java-version: Version of Java to use for the build. (default: openjdk8)
195     :mvn-global-settings: The name of the Maven global settings to use for
196         Maven configuration. (default: global-settings)
197     :mvn-opts: Sets MAVEN_OPTS. (default: '')
198     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
199     :mvn-version: Version of maven to use. (default: mvn35)
200     :stream: Keyword that can be used to represent a release code-name.
201         Often the same as the branch. (default: master)
202     :submodule-recursive: Whether to checkout submodules recursively.
203         (default: true)
204     :submodule-timeout: Timeout (in minutes) for checkout operation.
205         (default: 10)
206     :submodule-disable: Disable submodule checkout operation.
207         (default: false)
208
209     :gerrit_merge_triggers: Override Gerrit Triggers.
210
211 Maven JavaDoc Verify
212 --------------------
213
214 Produces javadocs for a Maven project.
215
216 Expects javadocs to be available in $WORKSPACE/target/site/apidocs
217
218 :Template Names:
219
220     - {project-name}-maven-javadoc-verify-{stream}-{java-version}
221     - gerrit-maven-javadoc-verify
222     - github-maven-javadoc-verify
223
224 :Comment Trigger: recheck|reverify
225
226 :Required parameters:
227     :build-node:    The node to run build on.
228     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
229         be configured in defaults.yaml)
230     :mvn-settings: The name of settings file containing credentials for the project.
231
232 :Optional parameters:
233
234     :branch: The branch to build against. (default: master)
235     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
236     :build-timeout: Timeout in minutes before aborting build. (default: 60)
237     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
238     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
239     :java-version: Version of Java to use for the build. (default: openjdk8)
240     :mvn-global-settings: The name of the Maven global settings to use for
241         Maven configuration. (default: global-settings)
242     :mvn-opts: Sets MAVEN_OPTS. (default: '')
243     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
244     :mvn-version: Version of maven to use. (default: mvn35)
245     :stream: Keyword that can be used to represent a release code-name.
246         Often the same as the branch. (default: master)
247     :submodule-recursive: Whether to checkout submodules recursively.
248         (default: true)
249     :submodule-timeout: Timeout (in minutes) for checkout operation.
250         (default: 10)
251     :submodule-disable: Disable submodule checkout operation.
252         (default: false)
253
254     :gerrit_verify_triggers: Override Gerrit Triggers.
255
256 Maven Merge
257 -----------
258
259 Merge job which runs `mvn clean deploy` to build a project.
260
261 This job pushes files to Nexus using cURL instead of allowing the Maven deploy
262 goal to push the upload. This is to get around the issue that Maven deploy does
263 not properly support uploading files at the end of the build and instead pushes
264 as it goes. There exists a `-Ddeploy-at-end` feature however it does not work
265 with extensions.
266
267 This job uses the following strategy to deploy jobs to Nexus:
268
269 1. `wget -r` to fetch maven-metadata.xml from Nexus
270 2. `mvn deploy -DaltDeploymentRepository` to prepare files for upload
271 3. Removes untouched maven-metadata.xml files before upload
272 4. Use lftools (cURL) upload script to push artifacts to Nexus
273
274 :Template Names:
275
276     - {project-name}-maven-merge-{stream}
277     - gerrit-maven-merge
278     - github-maven-merge
279
280 :Comment Trigger: remerge
281
282 :Required parameters:
283
284     :build-node: The node to run build on.
285     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
286         be configured in defaults.yaml)
287     :mvn-settings: The name of settings file containing credentials for the project.
288     :mvn-snapshot-id: Maven Server ID from settings.xml to pull credentials from.
289         (Note: This setting should be configured in defaults.yaml.)
290     :nexus-snapshot-repo: The repository id of the Nexus snapshot repo to deploy to.
291
292 :Optional parameters:
293
294     :branch: Git branch to fetch for the build. (default: master)
295     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
296     :build-timeout: Timeout in minutes before aborting build. (default: 60)
297     :cron: Cron schedule when to trigger the job. This parameter also
298         supports multiline input via YAML pipe | character in cases where
299         one may want to provide more than 1 cron timer. (default: 'H H * * 0'
300         to run weekly)
301     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
302     :java-version: Version of Java to use for the build. (default: openjdk8)
303     :mvn-global-settings: The name of the Maven global settings to use for
304         Maven configuration. (default: global-settings)
305     :mvn-opts: Sets MAVEN_OPTS. (default: '')
306     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
307     :mvn-version: Version of maven to use. (default: mvn35)
308     :nexus-cut-dirs: Number of directories to cut from file path for `wget -r`.
309     :stream: Keyword that can be used to represent a release code-name.
310         Often the same as the branch. (default: master)
311     :submodule-recursive: Whether to checkout submodules recursively.
312         (default: true)
313     :submodule-timeout: Timeout (in minutes) for checkout operation.
314         (default: 10)
315     :submodule-disable: Disable submodule checkout operation.
316         (default: false)
317
318     :gerrit_merge_triggers: Override Gerrit Triggers.
319     :gerrit_trigger_file_paths: Override file paths which can be used to
320         filter which file modifications will trigger a build.
321
322 Maven Merge for Docker
323 ----------------------
324
325 Produces a snapshot docker image in a Nexus registry. Appropriate for
326 Java projects that do not need to deploy any POM or JAR files.
327
328 Similar to Maven Merge as described above but logs in to Docker
329 registries first and skips the lf-maven-deploy builder. The project
330 POM file should invoke a plugin to build and push a Docker image. The
331 base image should be pulled from the registry in the environment
332 variable CONTAINER_PULL_REGISTRY. The new image should be pushed to the
333 registry in the environment variable CONTAINER_PUSH_REGISTRY.
334
335 :Template Names:
336
337     - {project-name}-maven-docker-merge-{stream}
338     - gerrit-maven-docker-merge
339     - github-maven-docker-merge
340
341 :Required parameters:
342
343     :container-public-registry: Docker registry source with base images.
344     :container-snapshot-registry: Docker registry target for the deploy action.
345
346 All other required and optional parameters are identical to the Maven Merge job
347 described above.
348
349 Maven Stage
350 -----------
351
352 Produces a release candidate by creating a staging repo in Nexus.
353
354 The staging repo name is in the format PROJECT-NUMBER for example "aaa-1234",
355 "autorelease-2000", "odlparent-1201", etc...
356
357 This job runs a Maven build and deploys to $WORKSPACE/m2repo directory. This
358 directory is then used later to deploy to Nexus.
359
360 :Template Names:
361
362     - {project-name}-maven-stage-{stream}
363     - gerrit-maven-stage
364     - github-maven-stage
365
366 :Comment Trigger: "stage-release" or "stage-maven-release"
367
368 :Required parameters:
369
370     :build-node: The node to run build on.
371     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
372         be configured in defaults.yaml)
373     :mvn-settings: The name of settings file containing credentials for the project.
374     :mvn-staging-id: Maven Server ID from settings.xml to pull credentials from.
375         (Note: This setting should be configured in defaults.yaml.)
376     :staging-profile-id: Profile ID of the project's Nexus staging profile.
377
378 :Optional parameters:
379
380     :archive-artifacts: Artifacts to archive to the logs server (default: '').
381     :branch: The branch to build against. (default: master)
382     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
383     :build-timeout: Timeout in minutes before aborting build. (default: 60)
384     :cron: Cron schedule when to trigger the job. This parameter also
385         supports multiline input via YAML pipe | character in cases where
386         one may want to provide more than 1 cron timer. (default: '')
387     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
388     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
389     :java-version: Version of Java to use for the build. (default: openjdk8)
390     :mvn-central: Set to 'true' to also stage to OSSRH. This is for projects
391         that want to release to Maven Central. If set the parameter
392         ``ossrh-profile-id`` also needs to be set. (default: false)
393     :maven-versions-plugin: Whether to call Maven versions plugin or not. (default: false)
394     :mvn-global-settings: The name of the Maven global settings to use for
395         Maven configuration. (default: global-settings)
396     :mvn-opts: Sets MAVEN_OPTS. (default: '')
397     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
398     :mvn-version: Version of maven to use. (default: mvn35)
399     :ossrh-profile-id: Profile ID for project as provided by OSSRH.
400         (default: '')
401     :sign-artifacts: Sign artifacts with Sigul. (default: false)
402     :stream: Keyword that can be used to represent a release code-name.
403         Often the same as the branch. (default: master)
404     :submodule-recursive: Whether to checkout submodules recursively.
405         (default: true)
406     :submodule-timeout: Timeout (in minutes) for checkout operation.
407         (default: 10)
408     :submodule-disable: Disable submodule checkout operation.
409         (default: false)
410     :version-properties-file: Name and path of the version properties file.
411         (default: version.properties)
412
413     :gerrit_release_triggers: Override Gerrit Triggers.
414     :gerrit_trigger_file_paths: Override file paths which can be used to
415         filter which file modifications will trigger a build.
416
417 Maven Stage for Docker
418 ----------------------
419
420 Produces a release candidate docker image in a Nexus registry.
421 Appropriate for Java projects that do not need to deploy any POM or
422 JAR files.
423
424 Similar to Maven Stage as described above but logs in to Docker
425 registries first and skips the lf-maven-deploy builder. The project
426 POM file should invoke a plugin to build and push a Docker image. The
427 base image should be pulled from the registry in the environment
428 variable CONTAINER_PULL_REGISTRY. The new image should be pushed to the
429 registry in the environment variable CONTAINER_PUSH_REGISTRY.
430
431 :Template Names:
432
433     - {project-name}-maven-docker-stage-{stream}
434     - gerrit-maven-docker-stage
435     - github-maven-docker-stage
436
437 :Comment Trigger: "stage-release" or "stage-docker-release"
438
439 :Required parameters:
440
441     :container-public-registry: Docker registry source with base images.
442     :container-staging-registry: Docker registry target for the deploy action.
443
444 :Optional parameters:
445
446     :gerrit_release_docker_triggers: Override Gerrit Triggers.
447
448 All other required and optional parameters are identical to the Maven Stage job
449 described above.
450
451 .. _maven-sonar:
452
453 Maven Sonar
454 -----------
455
456 Sonar job which runs mvn clean install then publishes to Sonar.
457
458 This job purposely only runs on the master branch as there are Additional
459 configuration needed to support multiple branches and there's not much
460 interest in that kind of support.
461
462 :Template Names:
463
464     - {project-name}-sonar
465     - gerrit-maven-sonar
466     - github-maven-sonar
467
468 :Comment Trigger: run-sonar
469
470 :Required parameters:
471
472     :build-node: The node to run build on.
473     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
474         be configured in defaults.yaml)
475     :mvn-settings: The name of settings file containing credentials for the project.
476
477 :Optional parameters:
478
479     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
480     :build-timeout: Timeout in minutes before aborting build. (default: 60)
481     :cron: Cron schedule when to trigger the job. This parameter also
482         supports multiline input via YAML pipe | character in cases where
483         one may want to provide more than 1 cron timer.  (default: 'H H * * 6'
484         to run weekly)
485     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
486     :java-version: Version of Java to use for the build. (default: openjdk8)
487     :mvn-global-settings: The name of the Maven global settings to use for
488         Maven configuration. (default: global-settings)
489     :mvn-goals: The maven goals to perform for the build.
490         (default: clean install)
491     :mvn-opts: Sets MAVEN_OPTS. (default: '')
492     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
493     :mvn-version: Version of maven to use. (default: mvn35)
494     :sonar-mvn-goals: Maven goals to run for sonar analysis.
495         (default: sonar:sonar)
496     :sonarcloud: Whether or not to use SonarCloud ``true|false``.
497         (default: false)
498     :sonarcloud-project-key: SonarCloud project key. (default: '')
499     :sonarcloud-project-organization: SonarCloud project organization.
500         (default: '')
501     :sonarcloud-api-token: SonarCloud API Token. (default: '')
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     :submodule-disable: Disable submodule checkout operation.
509         (default: false)
510
511     :gerrit_sonar_triggers: Override Gerrit Triggers.
512
513
514 SonarCloud Example:
515
516 .. literalinclude:: ../../.jjb-test/lf-maven-jobs/maven-sonarcloud.yaml
517    :language: yaml
518
519 Maven Verify
520 ------------
521
522 Verify job which runs mvn clean install to test a project build..
523
524 :Template Names:
525
526     - {project-name}-maven-verify-{stream}-{mvn-version}-{java-version}
527     - gerrit-maven-verify
528     - github-maven-verify
529
530 :Comment Trigger: recheck|reverify
531
532 :Required parameters:
533
534     :build-node: The node to run build on.
535     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
536         be configured in defaults.yaml)
537     :mvn-settings: The name of settings file containing credentials for the project.
538
539 :Optional parameters:
540
541     :branch: Git branch to fetch for the build. (default: master)
542     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
543     :build-timeout: Timeout in minutes before aborting build. (default: 60)
544     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
545     :java-version: Version of Java to use for the build. (default: openjdk8)
546     :mvn-global-settings: The name of the Maven global settings to use for
547         Maven configuration. (default: global-settings)
548     :mvn-opts: Sets MAVEN_OPTS. (default: '')
549     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
550     :mvn-version: Version of maven to use. (default: mvn35)
551     :stream: Keyword that can be used to represent a release code-name.
552         Often the same as the branch. (default: master)
553     :submodule-recursive: Whether to checkout submodules recursively.
554         (default: true)
555     :submodule-timeout: Timeout (in minutes) for checkout operation.
556         (default: 10)
557     :submodule-disable: Disable submodule checkout operation.
558         (default: false)
559
560     :gerrit_verify_triggers: Override Gerrit Triggers.
561     :gerrit_trigger_file_paths: Override file paths which can be used to
562         filter which file modifications will trigger a build.
563
564 Maven Verify for Docker
565 -----------------------
566
567 Similar to Maven Verify as described above but logs in to Docker
568 registries first. The project POM file should invoke a plugin to build
569 a Docker image. The base image should be pulled from the registry in
570 the environment variable CONTAINER_PULL_REGISTRY.
571
572 :Template Names:
573
574     - {project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}
575     - gerrit-maven-docker-verify
576     - github-maven-docker-verify
577
578 :Required parameters:
579
580     :container-public-registry: Docker registry source with base images.
581
582 All other required and optional parameters are identical to the Maven Verify job
583 described above.
584
585 Maven Verify w/ Dependencies
586 ----------------------------
587
588 Verify job which runs mvn clean install to test a project build /w deps
589
590 This job can be used to verify a patch in conjunction to all of the
591 upstream patches it depends on. The user of this job can provide a list
592 via comment trigger.
593
594 :Template Names:
595
596     - {project-name}-maven-verify-deps-{stream}-{mvn-version}-{java-version}
597     - gerrit-maven-verify-dependencies
598
599 :Comment Trigger: recheck: SPACE_SEPARATED_LIST_OF_PATCHES
600
601 :Required parameters:
602
603     :build-node: The node to run build on.
604     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
605         be configured in defaults.yaml)
606     :mvn-settings: The name of settings file containing credentials for the project.
607
608 :Optional parameters:
609
610     :branch: Git branch to fetch for the build. (default: master)
611     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
612     :build-timeout: Timeout in minutes before aborting build. (default: 60)
613     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
614     :java-version: Version of Java to use for the build. (default: openjdk8)
615     :mvn-global-settings: The name of the Maven global settings to use for
616         Maven configuration. (default: global-settings)
617     :mvn-opts: Sets MAVEN_OPTS. (default: '')
618     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
619     :mvn-version: Version of maven to use. (default: mvn35)
620     :stream: Keyword that can be used to represent a release code-name.
621         Often the same as the branch. (default: master)
622     :submodule-recursive: Whether to checkout submodules recursively.
623         (default: true)
624     :submodule-timeout: Timeout (in minutes) for checkout operation.
625         (default: 10)
626     :submodule-disable: Disable submodule checkout operation.
627         (default: false)
628
629     :gerrit_verify_triggers: Override Gerrit Triggers.
630     :gerrit_trigger_file_paths: Override file paths which can be used to
631         filter which file modifications will trigger a build.