Add missing file path triggers to maven stage jobs
[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     :submodule-disable: Disable submodule checkout operation.
145         (default: false)
146
147     :gerrit_merge_triggers: Override Gerrit Triggers.
148
149 Maven JavaDoc Publish
150 ---------------------
151
152 Produces and publishes javadocs for a Maven project.
153
154 Expects javadocs to be available in $WORKSPACE/target/site/apidocs
155
156 :Template Names:
157
158     - {project-name}-maven-javadoc-publish-{stream}-{java-version}
159     - gerrit-maven-javadoc-publish
160     - github-maven-javadoc-publish
161
162 :Comment Trigger: remerge
163
164 :Required parameters:
165
166     :build-node: The node to run build on.
167     :javadoc-path: The path in Nexus to deploy javadoc to.
168     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
169         be configured in defaults.yaml)
170     :mvn-settings: The name of settings file containing credentials for the project.
171     :mvn-site-id: Maven Server ID from settings.xml to pull credentials from.
172         (Note: This setting should be configured in defaults.yaml.)
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     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
180     :java-version: Version of Java to use for the build. (default: openjdk8)
181     :mvn-global-settings: The name of the Maven global settings to use for
182         Maven configuration. (default: global-settings)
183     :mvn-opts: Sets MAVEN_OPTS. (default: '')
184     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
185     :mvn-version: Version of maven to use. (default: mvn35)
186     :stream: Keyword that can be used to represent a release code-name.
187         Often the same as the branch. (default: master)
188     :submodule-recursive: Whether to checkout submodules recursively.
189         (default: true)
190     :submodule-timeout: Timeout (in minutes) for checkout operation.
191         (default: 10)
192     :submodule-disable: Disable submodule checkout operation.
193         (default: false)
194
195     :gerrit_merge_triggers: Override Gerrit Triggers.
196
197 Maven JavaDoc Verify
198 --------------------
199
200 Produces javadocs for a Maven project.
201
202 Expects javadocs to be available in $WORKSPACE/target/site/apidocs
203
204 :Template Names:
205
206     - {project-name}-maven-javadoc-verify-{stream}-{java-version}
207     - gerrit-maven-javadoc-verify
208     - github-maven-javadoc-verify
209
210 :Comment Trigger: recheck|reverify
211
212 :Required parameters:
213     :build-node:    The node to run build on.
214     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
215         be configured in defaults.yaml)
216     :mvn-settings: The name of settings file containing credentials for the project.
217
218 :Optional parameters:
219
220     :branch: The branch to build against. (default: master)
221     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
222     :build-timeout: Timeout in minutes before aborting build. (default: 60)
223     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
224     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
225     :java-version: Version of Java to use for the build. (default: openjdk8)
226     :mvn-global-settings: The name of the Maven global settings to use for
227         Maven configuration. (default: global-settings)
228     :mvn-opts: Sets MAVEN_OPTS. (default: '')
229     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
230     :mvn-version: Version of maven to use. (default: mvn35)
231     :stream: Keyword that can be used to represent a release code-name.
232         Often the same as the branch. (default: master)
233     :submodule-recursive: Whether to checkout submodules recursively.
234         (default: true)
235     :submodule-timeout: Timeout (in minutes) for checkout operation.
236         (default: 10)
237     :submodule-disable: Disable submodule checkout operation.
238         (default: false)
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     :submodule-disable: Disable submodule checkout operation.
302         (default: false)
303
304     :gerrit_merge_triggers: Override Gerrit Triggers.
305     :gerrit_trigger_file_paths: Override file paths which can be used to
306         filter which file modifications will trigger a build.
307
308 Maven Merge for Docker
309 ----------------------
310
311 Produces a snapshot docker image in a Nexus registry. Appropriate for
312 Java projects that do not need to deploy any POM or JAR files.
313
314 Similar to Maven Merge as described above but logs in to Docker
315 registries first and skips the lf-maven-deploy builder. The project
316 POM file should invoke a plugin to build and push a Docker image. The
317 base image should be pulled from the registry in the environment
318 variable CONTAINER_PULL_REGISTRY. The new image should be pushed to the
319 registry in the environment variable CONTAINER_PUSH_REGISTRY.
320
321 :Template Names:
322
323     - {project-name}-maven-docker-merge-{stream}
324     - gerrit-maven-docker-merge
325     - github-maven-docker-merge
326
327 :Required parameters:
328
329     :container-public-registry: Docker registry source with base images.
330     :container-snapshot-registry: Docker registry target for the deploy action.
331
332 All other required and optional parameters are identical to the Maven Merge job
333 described above.
334
335 Maven Stage
336 -----------
337
338 Produces a release candidate by creating a staging repo in Nexus.
339
340 The staging repo name is in the format PROJECT-NUMBER for example "aaa-1234",
341 "autorelease-2000", "odlparent-1201", etc...
342
343 This job runs a Maven build and deploys to $WORKSPACE/m2repo directory. This
344 directory is then used later to deploy to Nexus.
345
346 :Template Names:
347
348     - {project-name}-maven-stage-{stream}
349     - gerrit-maven-stage
350     - github-maven-stage
351
352 :Required parameters:
353
354     :build-node: The node to run build on.
355     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
356         be configured in defaults.yaml)
357     :mvn-settings: The name of settings file containing credentials for the project.
358     :mvn-staging-id: Maven Server ID from settings.xml to pull credentials from.
359         (Note: This setting should be configured in defaults.yaml.)
360     :staging-profile-id: Profile ID of the project's Nexus staging profile.
361
362 :Optional parameters:
363
364     :archive-artifacts: Artifacts to archive to the logs server (default: '').
365     :branch: The branch to build against. (default: master)
366     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
367     :build-timeout: Timeout in minutes before aborting build. (default: 60)
368     :cron: Cron schedule when to trigger the job. This parameter also
369         supports multiline input via YAML pipe | character in cases where
370         one may want to provide more than 1 cron timer. (default: '')
371     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
372     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
373     :java-version: Version of Java to use for the build. (default: openjdk8)
374     :mvn-central: Set to 'true' to also stage to OSSRH. This is for projects
375         that want to release to Maven Central. If set the parameter
376         ``ossrh-profile-id`` also needs to be set. (default: false)
377     :maven-versions-plugin: Whether to call Maven versions plugin or not. (default: false)
378     :mvn-global-settings: The name of the Maven global settings to use for
379         Maven configuration. (default: global-settings)
380     :mvn-opts: Sets MAVEN_OPTS. (default: '')
381     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
382     :mvn-version: Version of maven to use. (default: mvn35)
383     :ossrh-profile-id: Profile ID for project as provided by OSSRH.
384         (default: '')
385     :sign-artifacts: Sign artifacts with Sigul. (default: false)
386     :stream: Keyword that can be used to represent a release code-name.
387         Often the same as the branch. (default: master)
388     :submodule-recursive: Whether to checkout submodules recursively.
389         (default: true)
390     :submodule-timeout: Timeout (in minutes) for checkout operation.
391         (default: 10)
392     :submodule-disable: Disable submodule checkout operation.
393         (default: false)
394
395     :gerrit_release_triggers: Override Gerrit Triggers.
396     :gerrit_trigger_file_paths: Override file paths which can be used to
397         filter which file modifications will trigger a build.
398
399 Maven Stage for Docker
400 ----------------------
401
402 Produces a release candidate docker image in a Nexus registry.
403 Appropriate for Java projects that do not need to deploy any POM or
404 JAR files.
405
406 Similar to Maven Stage as described above but logs in to Docker
407 registries first and skips the lf-maven-deploy builder. The project
408 POM file should invoke a plugin to build and push a Docker image. The
409 base image should be pulled from the registry in the environment
410 variable CONTAINER_PULL_REGISTRY. The new image should be pushed to the
411 registry in the environment variable CONTAINER_PUSH_REGISTRY.
412
413 :Template Names:
414
415     - {project-name}-maven-docker-stage-{stream}
416     - gerrit-maven-docker-stage
417     - github-maven-docker-stage
418
419 :Required parameters:
420
421     :container-public-registry: Docker registry source with base images.
422     :container-staging-registry: Docker registry target for the deploy action.
423
424 All other required and optional parameters are identical to the Maven Stage job
425 described above.
426
427 .. _maven-sonar:
428
429 Maven Sonar
430 -----------
431
432 Sonar job which runs mvn clean install then publishes to Sonar.
433
434 This job purposely only runs on the master branch as there are Additional
435 configuration needed to support multiple branches and there's not much
436 interest in that kind of support.
437
438 :Template Names:
439
440     - {project-name}-sonar
441     - gerrit-maven-sonar
442     - github-maven-sonar
443
444 :Comment Trigger: run-sonar
445
446 :Required parameters:
447
448     :build-node: The node to run build on.
449     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
450         be configured in defaults.yaml)
451     :mvn-settings: The name of settings file containing credentials for the project.
452
453 :Optional parameters:
454
455     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
456     :build-timeout: Timeout in minutes before aborting build. (default: 60)
457     :cron: Cron schedule when to trigger the job. This parameter also
458         supports multiline input via YAML pipe | character in cases where
459         one may want to provide more than 1 cron timer.  (default: 'H H * * 6'
460         to run weekly)
461     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
462     :java-version: Version of Java to use for the build. (default: openjdk8)
463     :mvn-global-settings: The name of the Maven global settings to use for
464         Maven configuration. (default: global-settings)
465     :mvn-opts: Sets MAVEN_OPTS. (default: '')
466     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
467     :mvn-version: Version of maven to use. (default: mvn35)
468     :sonar-mvn-goals: Maven goals to run for sonar analysis.
469         (default: sonar:sonar)
470     :sonarcloud: Whether or not to use SonarCloud ``true|false``.
471         (default: false)
472     :sonarcloud-project-key: SonarCloud project key. (default: '')
473     :sonarcloud-project-organization: SonarCloud project organization.
474         (default: '')
475     :sonarcloud-api-token: SonarCloud API Token. (default: '')
476     :stream: Keyword that can be used to represent a release code-name.
477         Often the same as the branch. (default: master)
478     :submodule-recursive: Whether to checkout submodules recursively.
479         (default: true)
480     :submodule-timeout: Timeout (in minutes) for checkout operation.
481         (default: 10)
482     :submodule-disable: Disable submodule checkout operation.
483         (default: false)
484
485     :gerrit_sonar_triggers: Override Gerrit Triggers.
486
487
488 SonarCloud Example:
489
490 .. literalinclude:: ../../.jjb-test/lf-maven-jobs/maven-sonarcloud.yaml
491    :language: yaml
492
493 Maven Verify
494 ------------
495
496 Verify job which runs mvn clean install to test a project build..
497
498 :Template Names:
499
500     - {project-name}-maven-verify-{stream}-{mvn-version}-{java-version}
501     - gerrit-maven-verify
502     - github-maven-verify
503
504 :Comment Trigger: recheck|reverify
505
506 :Required parameters:
507
508     :build-node: The node to run build on.
509     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
510         be configured in defaults.yaml)
511     :mvn-settings: The name of settings file containing credentials for the project.
512
513 :Optional parameters:
514
515     :branch: Git branch to fetch for the build. (default: master)
516     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
517     :build-timeout: Timeout in minutes before aborting build. (default: 60)
518     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
519     :java-version: Version of Java to use for the build. (default: openjdk8)
520     :mvn-global-settings: The name of the Maven global settings to use for
521         Maven configuration. (default: global-settings)
522     :mvn-opts: Sets MAVEN_OPTS. (default: '')
523     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
524     :mvn-version: Version of maven to use. (default: mvn35)
525     :stream: Keyword that can be used to represent a release code-name.
526         Often the same as the branch. (default: master)
527     :submodule-recursive: Whether to checkout submodules recursively.
528         (default: true)
529     :submodule-timeout: Timeout (in minutes) for checkout operation.
530         (default: 10)
531     :submodule-disable: Disable submodule checkout operation.
532         (default: false)
533
534     :gerrit_verify_triggers: Override Gerrit Triggers.
535     :gerrit_trigger_file_paths: Override file paths which can be used to
536         filter which file modifications will trigger a build.
537
538 Maven Verify for Docker
539 -----------------------
540
541 Similar to Maven Verify as described above but logs in to Docker
542 registries first. The project POM file should invoke a plugin to build
543 a Docker image. The base image should be pulled from the registry in
544 the environment variable CONTAINER_PULL_REGISTRY.
545
546 :Template Names:
547
548     - {project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}
549     - gerrit-maven-docker-verify
550     - github-maven-docker-verify
551
552 :Required parameters:
553
554     :container-public-registry: Docker registry source with base images.
555
556 All other required and optional parameters are identical to the Maven Verify job
557 described above.
558
559 Maven Verify w/ Dependencies
560 ----------------------------
561
562 Verify job which runs mvn clean install to test a project build /w deps
563
564 This job can be used to verify a patch in conjunction to all of the
565 upstream patches it depends on. The user of this job can provide a list
566 via comment trigger.
567
568 :Template Names:
569
570     - {project-name}-maven-verify-deps-{stream}-{mvn-version}-{java-version}
571     - gerrit-maven-verify-dependencies
572
573 :Comment Trigger: recheck: SPACE_SEPARATED_LIST_OF_PATCHES
574
575 :Required parameters:
576
577     :build-node: The node to run build on.
578     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
579         be configured in defaults.yaml)
580     :mvn-settings: The name of settings file containing credentials for the project.
581
582 :Optional parameters:
583
584     :branch: Git branch to fetch for the build. (default: master)
585     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
586     :build-timeout: Timeout in minutes before aborting build. (default: 60)
587     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
588     :java-version: Version of Java to use for the build. (default: openjdk8)
589     :mvn-global-settings: The name of the Maven global settings to use for
590         Maven configuration. (default: global-settings)
591     :mvn-opts: Sets MAVEN_OPTS. (default: '')
592     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
593     :mvn-version: Version of maven to use. (default: mvn35)
594     :stream: Keyword that can be used to represent a release code-name.
595         Often the same as the branch. (default: master)
596     :submodule-recursive: Whether to checkout submodules recursively.
597         (default: true)
598     :submodule-timeout: Timeout (in minutes) for checkout operation.
599         (default: 10)
600     :submodule-disable: Disable submodule checkout operation.
601         (default: false)
602
603     :gerrit_verify_triggers: Override Gerrit Triggers.
604     :gerrit_trigger_file_paths: Override file paths which can be used to
605         filter which file modifications will trigger a build.