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