Feat: Add Maven Snyk CLI Scanner
[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. (default: openjdk11)
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 Maven build. (default: openjdk11)
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-java-version: Version of Java to run the Sonar scan. (default: openjdk11)
43     :sonarcloud-qualitygate-wait: SonarCloud flag that forces the analysis step to
44         wait for the quality gate result. (default: false)
45
46 lf-maven-build
47 --------------
48
49 Calls the maven build script to perform a maven build.
50
51 :Required parameters:
52
53     :mvn-goals: The maven goals to perform for the build.
54         (default: clean deploy)
55
56 lf-maven-common
57 ---------------
58
59 Common Jenkins configuration for Maven jobs.
60
61 lf-maven-deploy
62 ---------------
63
64 Calls the maven deploy script to push artifacts to Nexus.
65
66 lf-maven-versions-plugin
67 ------------------------
68
69 Conditionally calls Maven versions plugin to set, update and commit the maven `versions:set`.
70
71 :Required Parameters:
72
73     :maven-versions-plugin: Whether to call Maven versions plugin or not. (default: false)
74     :version-properties-file: Name and path of the version properties file.
75         (default: version.properties)
76     :mvn-version: Version of Maven to execute Sonar with.
77     :mvn-pom: Location of pom.xml.
78     :mvn-settings: Maven settings.xml file containing credentials to use.
79
80 lf-maven-stage
81 --------------
82
83 Calls the maven stage script to push artifacts to a Nexus staging repository.
84
85 :Required Parameters:
86
87     :mvn-global-settings: The name of the Maven global settings to use for
88         Maven configuration.
89     :mvn-settings: The name of settings file containing credentials for the project.
90
91 lf-update-java-alternatives
92 ---------------------------
93
94 Setup Java alternatives for the Distro.
95
96 :Required Parameters:
97
98     :java-version: Version of Java to set as the default Java.
99         Eg. openjdk11
100
101 lf-infra-sonatype-clm
102 ---------------------
103
104 Runs a Sonatype CLM scan against a Maven project and pushes results to
105 Nexus IQ server.
106
107 :Optional parameters:
108     :mvn-goals: The maven goals to perform for the build.
109         (default: clean install)
110
111 lf-infra-snyk-cli-scanner
112 -------------------------
113
114 Downloads the latest Snyk CLI and triggers a code scan. It publishes a report into
115 the Snyk dashboard.
116
117 :Optional parameters:
118     :mvn-goals: The maven goals to perform for the build.
119         (default: clean install)
120
121 lf-infra-maven-sbom-generator
122 -----------------------------
123
124 Runs a specific version of SPDX SBOM Generator tool to generate a report.
125 The calling job template sets the version to run in the SBOM_GENERATOR_VERSION parameter.
126
127 :Optional parameters:
128     :sbom-flags: SBOM generator options. See https://github.com/opensbom-generator/spdx-sbom-generator
129
130 Job Templates
131 =============
132
133 Maven CLM
134 ---------
135
136 Produces a CLM scan of the code into Nexus IQ Server.
137
138 :Template Names:
139
140     - {project-name}-maven-clm-{stream}
141     - gerrit-maven-clm
142     - github-maven-clm
143
144 :Comment Trigger: run-clm
145
146 :Required parameters:
147
148     :build-node:    The node to run build on.
149     :jenkins-ssh-credential: Credential to use for SSH. (Generally configured in defaults.yaml)
150     :mvn-settings: The name of settings file containing credentials for the project.
151
152 :Optional parameters:
153
154     :branch: The branch to build against. (default: master)
155     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
156     :build-timeout: Timeout in minutes before aborting build. (default: 60)
157     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
158     :java-version: Version of Java to use for the build. (default: openjdk11)
159     :mvn-global-settings: The name of the Maven global settings to use for
160         Maven configuration. (default: global-settings)
161     :mvn-goals: The maven goals to perform for the build.
162         (default: clean install)
163     :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '')
164     :mvn-params: Parameters to pass to the mvn CLI. (default: '')
165     :mvn-version: Version of maven to use. (default: mvn35)
166     :nexus-iq-namespace: Insert a namespace to project AppID for projects that
167         share a Nexus IQ system to avoid project name collision. We recommend
168         inserting a trailing - dash if using this parameter.
169         For example 'odl-'. (default: '')
170     :nexus-iq-stage: Sets the **stage** which the policy evaluation will run
171         against on the Nexus IQ Server. (default: 'build')
172     :stream: Keyword that represents a release code-name.
173         Often the same as the branch. (default: master)
174     :submodule-recursive: Whether to checkout submodules recursively.
175         (default: true)
176     :submodule-timeout: Timeout (in minutes) for checkout operation.
177         (default: 10)
178     :submodule-disable: Disable submodule checkout operation.
179         (default: false)
180
181     :gerrit_merge_triggers: Override Gerrit Triggers.
182
183 Maven SNYK CLI
184 --------------
185
186 Builds the code, downloads and runs a Snyk CLI scan of the code into the Snyk dashboard.
187
188 :Template Names:
189
190     - {project-name}-maven-snyk-cli-{stream}
191     - gerrit-maven-snyk-cli
192     - github-maven-snyk-cli
193
194 :Comment Trigger: run-snyk
195
196 :Required parameters:
197
198     :build-node:    The node to run build on.
199     :jenkins-ssh-credential: Credential to use for SSH. (Generally configured in defaults.yaml)
200     :mvn-settings: The name of settings file containing credentials for the project.
201     :snyk-token-credential-id: Snyk API token to communicate with Jenkins.
202     :snyk-org-credential-id: Snyk organization ID.
203
204 :Optional parameters:
205
206     :branch: The branch to build against. (default: master)
207     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
208     :build-timeout: Timeout in minutes before aborting build. (default: 60)
209     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
210     :java-version: Version of Java to use for the build. (default: openjdk11)
211     :mvn-global-settings: The name of the Maven global settings to use for
212         Maven configuration. (default: global-settings)
213     :mvn-goals: The maven goals to perform for the build.
214         (default: clean install)
215     :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '')
216     :mvn-params: Parameters to pass to the mvn CLI. (default: '')
217     :mvn-version: Version of maven to use. (default: mvn35)
218     :stream: Keyword that represents a release code-name.
219         Often the same as the branch. (default: master)
220     :submodule-recursive: Whether to checkout submodules recursively.
221         (default: true)
222     :submodule-timeout: Timeout (in minutes) for checkout operation.
223         (default: 10)
224     :submodule-disable: Disable submodule checkout operation.
225         (default: false)
226
227     :gerrit_snyk_triggers: Override Gerrit Triggers.
228
229 Maven JavaDoc Publish
230 ---------------------
231
232 Produces and publishes javadocs for a Maven project.
233
234 Expects javadocs to be available in ``$WORKSPACE/target/site/apidocs``, but
235 overrideable with the ``mvn-dir`` parameter. If set, will search for javadocs
236 in ``$WORKSPACE/{mvn-dir}/target/site/apidocs``.
237
238 :Template Names:
239
240     - {project-name}-maven-javadoc-publish-{stream}-{java-version}
241     - gerrit-maven-javadoc-publish
242     - github-maven-javadoc-publish
243
244 :Comment Trigger: remerge
245
246 :Required parameters:
247
248     :build-node: The node to run build on.
249     :javadoc-path: The path in Nexus to deploy javadoc to.
250     :jenkins-ssh-credential: Credential to use for SSH. (Generally configured in defaults.yaml)
251     :mvn-settings: The name of settings file containing credentials for the project.
252     :mvn-site-id: Maven Server ID from settings.xml to pull credentials from.
253         (Note: This setting is generally configured in ``defaults.yaml``.)
254
255 :Optional parameters:
256
257     :branch: The branch to build against. (default: master)
258     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
259     :build-timeout: Timeout in minutes before aborting build. (default: 60)
260     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
261     :java-version: Version of Java to use for the build. (default: openjdk11)
262     :mvn-dir: Directory supplied as argument to -f option (default: '.')
263     :mvn-global-settings: The name of the Maven global settings to use for
264         Maven configuration. (default: global-settings)
265     :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '')
266     :mvn-params: Parameters to pass to the mvn CLI. (default: '')
267         Must not include a "-f" option; see parameter mvn-dir.
268     :mvn-version: Version of maven to use. (default: mvn35)
269     :stream: Keyword that represents a release code-name.
270         Often the same as the branch. (default: master)
271     :submodule-recursive: Whether to checkout submodules recursively.
272         (default: true)
273     :submodule-timeout: Timeout (in minutes) for checkout operation.
274         (default: 10)
275     :submodule-disable: Disable submodule checkout operation.
276         (default: false)
277
278     :gerrit_merge_triggers: Override Gerrit Triggers.
279
280 Maven JavaDoc Verify
281 --------------------
282
283 Produces javadocs for a Maven project.
284
285 Expects javadocs to be available in ``$WORKSPACE/target/site/apidocs``, but
286 overrideable with the ``mvn-dir`` parameter. If set, will search for javadocs
287 in ``$WORKSPACE/{mvn-dir}/target/site/apidocs``.
288
289 :Template Names:
290
291     - {project-name}-maven-javadoc-verify-{stream}-{java-version}
292     - gerrit-maven-javadoc-verify
293     - github-maven-javadoc-verify
294
295 :Comment Trigger: recheck|reverify
296
297 :Required parameters:
298     :build-node:    The node to run build on.
299     :jenkins-ssh-credential: Credential to use for SSH. (Generally configured in defaults.yaml)
300     :mvn-settings: The name of settings file containing credentials for the project.
301
302 :Optional parameters:
303
304     :branch: The branch to build against. (default: master)
305     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
306     :build-timeout: Timeout in minutes before aborting build. (default: 60)
307     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
308     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
309     :java-version: Version of Java to use for the build. (default: openjdk11)
310     :mvn-dir: Directory supplied as argument to -f option (default: '.')
311     :mvn-global-settings: The name of the Maven global settings to use for
312         Maven configuration. (default: global-settings)
313     :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '')
314     :mvn-params: Parameters to pass to the mvn CLI. (default: '')
315         Must not include a "-f" option; see parameter mvn-dir.
316     :mvn-version: Version of maven to use. (default: mvn35)
317     :stream: Keyword that represents a release code-name.
318         Often the same as the branch. (default: master)
319     :submodule-recursive: Whether to checkout submodules recursively.
320         (default: true)
321     :submodule-timeout: Timeout (in minutes) for checkout operation.
322         (default: 10)
323     :submodule-disable: Disable submodule checkout operation.
324         (default: false)
325
326     :gerrit_verify_triggers: Override Gerrit Triggers.
327
328 Maven Merge
329 -----------
330
331 Merge job which runs `mvn clean deploy` to build a project.
332
333 This job pushes files to Nexus using cURL instead of allowing the Maven deploy
334 goal to push the upload. This is to get around the issue that Maven deploy does
335 not properly support uploading files at the end of the build and instead pushes
336 as it goes. There exists a ``-Ddeploy-at-end`` feature but it does not work
337 with extensions.
338
339 This job uses the following strategy to deploy jobs to Nexus:
340
341 1. ``wget -r`` to fetch maven-metadata.xml from Nexus
342 2. ``mvn deploy -DaltDeploymentRepository`` to prepare files for upload
343 3. Removes untouched maven-metadata.xml files before upload
344 4. Use lftools (cURL) upload script to push artifacts to Nexus
345
346 :Template Names:
347
348     - {project-name}-maven-merge-{stream}
349     - gerrit-maven-merge
350     - github-maven-merge
351
352 :Comment Trigger: remerge
353
354 :Required parameters:
355
356     :build-node: The node to run build on.
357     :jenkins-ssh-credential: Credential to use for SSH. (Generally configured in defaults.yaml)
358     :mvn-settings: The name of settings file containing credentials for the project.
359     :mvn-snapshot-id: Maven Server ID from settings.xml to pull credentials from.
360         (Note: This setting is generally configured in ``defaults.yaml``.)
361     :nexus-snapshot-repo: The repository id of the Nexus snapshot repo to deploy to.
362
363 :Optional parameters:
364
365     :branch: Git branch to fetch for the build. (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: 'H H * * 0'
371         to run weekly)
372     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
373     :java-version: Version of Java to use for the build. (default: openjdk11)
374     :mvn-global-settings: The name of the Maven global settings to use for
375         Maven configuration. (default: global-settings)
376     :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '')
377     :mvn-params: Parameters to pass to the mvn CLI. (default: '')
378     :mvn-version: Version of maven to use. (default: mvn35)
379     :nexus-cut-dirs: Number of directories to cut from file path for `wget -r`.
380     :pre-build-script: Shell script to run before maven build. (default: a string with a shell comment)
381     :post-build-script: Shell script to run after maven build. (default: a string with a shell comment)
382     :stream: Keyword that represents a release code-name.
383         Often the same as the branch. (default: master)
384     :submodule-recursive: Whether to checkout submodules recursively.
385         (default: true)
386     :submodule-timeout: Timeout (in minutes) for checkout operation.
387         (default: 10)
388     :submodule-disable: Disable submodule checkout operation.
389         (default: false)
390
391     :gerrit_merge_triggers: Override Gerrit Triggers.
392     :gerrit_trigger_file_paths: Override file paths to filter which file
393         modifications will trigger a build.
394
395 Maven Merge for Docker
396 ----------------------
397
398 Produces a snapshot docker image in a Nexus registry. Appropriate for
399 Java projects that do not need to deploy any POM or JAR files.
400
401 Like the Maven Merge job as described above but logs in to Docker
402 registries first and skips the lf-maven-deploy builder. The project
403 POM file should invoke a plugin to build and push a Docker image.
404 This pulls the base image from the registry in the environment
405 variable ``CONTAINER_PULL_REGISTRY`` and pushes new image into the
406 registry in the environment variable ``CONTAINER_PUSH_REGISTRY``.
407
408 :Template Names:
409
410     - {project-name}-maven-docker-merge-{stream}
411     - gerrit-maven-docker-merge
412     - github-maven-docker-merge
413
414 :Required parameters:
415
416     :container-public-registry: Docker registry source with base images.
417     :container-snapshot-registry: Docker registry target for the deploy action.
418
419 All other required and optional parameters are identical to the Maven Merge job
420 described above.
421
422 Maven Stage
423 -----------
424
425 Produces a release candidate by creating a staging repo in Nexus.
426
427 The staging repo name is in the format PROJECT-NUMBER for example "aaa-1234",
428 "autorelease-2000", "odlparent-1201", etc...
429
430 This job runs a Maven build and deploys to $WORKSPACE/m2repo directory. This
431 directory is then used later to deploy to Nexus.
432
433 :Template Names:
434
435     - {project-name}-maven-stage-{stream}
436     - gerrit-maven-stage
437     - github-maven-stage
438
439 :Comment Trigger: "stage-release" or "stage-maven-release"
440
441 :Required parameters:
442
443     :build-node: The node to run build on.
444     :jenkins-ssh-credential: Credential to use for SSH. (Generally configured in defaults.yaml)
445     :mvn-settings: The name of settings file containing credentials for the project.
446     :mvn-staging-id: Maven Server ID from settings.xml to pull credentials from.
447         (Note: This setting is generally configured in ``defaults.yaml``.)
448     :staging-profile-id: Profile ID of the project's Nexus staging profile.
449
450 :Optional parameters:
451
452     :archive-artifacts: Artifacts to archive to the logs server (default: '').
453     :branch: The branch to build against. (default: master)
454     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
455     :build-timeout: Timeout in minutes before aborting build. (default: 60)
456     :cron: Cron schedule when to trigger the job. This parameter also
457         supports multiline input via YAML pipe | character in cases where
458         one may want to provide more than 1 cron timer. (default: '')
459     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
460     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
461     :java-version: Version of Java to use for the build. (default: openjdk11)
462     :mvn-central: Set to ``true`` to also stage to **OSSRH**. This is for projects
463         that want to release to Maven Central. If set, then also set the parameter
464         ``ossrh-profile-id``. (default: false)
465     :maven-versions-plugin: Whether to call Maven versions plugin or not. (default: false)
466     :mvn-global-settings: The name of the Maven global settings to use for
467         Maven configuration. (default: global-settings)
468     :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '')
469     :mvn-params: Parameters to pass to the mvn CLI. (default: '')
470     :mvn-version: Version of maven to use. (default: mvn35)
471     :ossrh-profile-id: Profile ID for project as provided by OSSRH.
472         (default: '')
473     :sbom-flags: SBOM generator options if using sbom-generator.
474         See https://github.com/opensbom-generator/spdx-sbom-generator
475     :sbom-generator: Calls lf-infra-maven-sbom-generator to run the SPDX SBOM generator tool.
476         (default: false)
477     :sbom-generator-version: SBOM generator version to download and run if using sbom-generator.
478         (default: v0.0.10)
479     :sbom-path: Path where SBOM is going to be executed from.
480         (default: $WORKSPACE)
481     :sign-artifacts: Sign artifacts with Sigul. (default: false)
482     :stream: Keyword that represents a release code-name.
483         Often the same as the branch. (default: master)
484     :submodule-recursive: Whether to checkout submodules recursively.
485         (default: true)
486     :submodule-timeout: Timeout (in minutes) for checkout operation.
487         (default: 10)
488     :submodule-disable: Disable submodule checkout operation.
489         (default: false)
490     :version-properties-file: Name and path of the version properties file.
491         (default: version.properties)
492
493     :gerrit_release_triggers: Override Gerrit Triggers.
494     :gerrit_trigger_file_paths: Override file paths to filter which file
495         modifications will trigger a build.
496
497 Maven Stage for Docker
498 ----------------------
499
500 Produces a release candidate docker image in a Nexus registry.
501 Appropriate for Java projects that do not need to deploy any POM or
502 JAR files.
503
504 Like the Maven Stage job as described above but logs in to Docker
505 registries first and skips the lf-maven-deploy builder. The project
506 POM file should invoke a plugin to build and push a Docker image.
507 This pulls the base image from the registry in the environment
508 variable ``CONTAINER_PULL_REGISTRY`` and pushes new image into the
509 registry in the environment variable ``CONTAINER_PUSH_REGISTRY``.
510
511 :Template Names:
512
513     - {project-name}-maven-docker-stage-{stream}
514     - gerrit-maven-docker-stage
515     - github-maven-docker-stage
516
517 :Comment Trigger: "stage-release" or "stage-docker-release"
518
519 :Required parameters:
520
521     :container-public-registry: Docker registry source with base images.
522     :container-staging-registry: Docker registry target for the deploy action.
523
524 :Optional parameters:
525
526     :gerrit_release_docker_triggers: Override Gerrit Triggers.
527
528 All other required and optional parameters are identical to the Maven Stage job
529 described above.
530
531 .. _maven-sonar:
532
533 Maven Sonar
534 -----------
535
536 Sonar job which runs mvn clean install then publishes to Sonar.
537
538 This job purposely runs on the ``master`` branch and does not support
539 multi-branch configuration.
540
541 :Template Names:
542
543     - {project-name}-sonar
544     - gerrit-maven-sonar
545     - github-maven-sonar
546     - {project-name}-sonar-prescan-script
547     - gerrit-maven-sonar-prescan-script
548     - github-maven-sonar-prescan-script
549
550 :Comment Trigger: run-sonar
551
552 :Required parameters:
553
554     :build-node: The node to run build on.
555     :jenkins-ssh-credential: Credential to use for SSH. (Generally configured in defaults.yaml)
556     :mvn-settings: The name of settings file containing credentials for the project.
557     :sonar-prescan-script: (maven-sonar-prescan-script jobs) A shell script to run before
558         sonar scans.
559
560 :Optional parameters:
561
562     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
563     :build-timeout: Timeout in minutes before aborting build. (default: 60)
564     :cron: Cron schedule when to trigger the job. This parameter also
565         supports multiline input via YAML pipe | character in cases where
566         one may want to provide more than 1 cron timer.  (default: 'H H * * 6'
567         to run weekly)
568     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
569     :java-version: Version of Java to use for the Maven build. (default: openjdk11)
570     :mvn-global-settings: The name of the Maven global settings to use for
571         Maven configuration. (default: global-settings)
572     :mvn-goals: The maven goals to perform for the build.
573         (default: clean install)
574     :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '')
575     :mvn-params: Parameters to pass to the mvn CLI. (default: '')
576     :mvn-version: Version of maven to use. (default: mvn35)
577     :sonar-mvn-goals: Maven goals to run for sonar analysis.
578         (default: sonar:sonar)
579     :sonarcloud: Set to ``true`` to use SonarCloud ``true|false``.
580         (default: false)
581     :sonarcloud-project-key: SonarCloud project key. (default: '')
582     :sonarcloud-project-organization: SonarCloud project organization.
583         (default: '')
584     :sonarcloud-api-token-cred-id: Jenkins credential ID which has the SonarCloud API Token.
585         This one SHOULDN'T be overwritten as per we are standarizing the credential ID for all
586         projects (default: 'sonarcloud-api-token')
587     :sonarcloud-java-version: Version of Java to use for the Sonar scan. (default: openjdk11)
588     :stream: Keyword that represents a release code-name.
589         Often the same as the branch. (default: master)
590     :submodule-recursive: Whether to checkout submodules recursively.
591         (default: true)
592     :submodule-timeout: Timeout (in minutes) for checkout operation.
593         (default: 10)
594     :submodule-disable: Disable submodule checkout operation.
595         (default: false)
596     :scan-dev-branch: Run the scan on a developer branch.
597         (default: false)
598
599     :gerrit_sonar_triggers: Override Gerrit Triggers.
600
601
602 SonarCloud Example:
603
604 .. literalinclude:: ../../.jjb-test/lf-maven-jobs/maven-sonarcloud.yaml
605    :language: yaml
606
607 Maven Sonar Verify
608 ------------------
609
610 Sonar job which runs mvn clean install then publishes to Sonar.
611
612 This job runs on dev branches and its triggered on new patchsets.
613
614 :Template Names:
615
616     - {project-name}-sonar-verify
617     - gerrit-maven-sonar-verify
618
619 :Comment Trigger: recheck|reverify
620
621 :Required parameters:
622
623     :build-node: The node to run build on.
624     :jenkins-ssh-credential: Credential to use for SSH. (Generally configured in defaults.yaml)
625     :mvn-settings: The name of settings file containing credentials for the project.
626
627 :Optional parameters:
628
629     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
630     :build-timeout: Timeout in minutes before aborting build. (default: 60)
631     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
632     :java-version: Version of Java to use for the Maven build. (default: openjdk11)
633     :mvn-global-settings: The name of the Maven global settings to use for
634         Maven configuration. (default: global-settings)
635     :mvn-goals: The maven goals to perform for the build.
636         (default: clean install)
637     :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '')
638     :mvn-params: Parameters to pass to the mvn CLI. (default: '')
639     :mvn-version: Version of maven to use. (default: mvn35)
640     :pre-build-script: Shell script to run before maven build. (default: a string with a shell comment)
641     :post-build-script: Shell script to run after maven build. (default: a string with a shell comment)
642     :sonar-mvn-goal: Maven goals to run for sonar analysis.
643         (default: sonar:sonar)
644     :sonarcloud: Set to ``true`` to use SonarCloud ``true|false``.
645         (default: true)
646     :sonarcloud-project-key: SonarCloud project key. (default: '')
647     :sonarcloud-project-organization: SonarCloud project organization.
648         (default: '')
649     :sonarcloud-api-token-cred-id: Jenkins credential ID which has the SonarCloud API Token.
650         This one SHOULDN'T be overwritten as per we are standarizing the credential ID for all
651         projects (default: 'sonarcloud-api-token')
652     :sonarcloud-java-version: Version of Java to use for the Sonar scan. (default: openjdk11)
653     :sonarcloud-qualitygate-wait: SonarCloud flag that forces the analysis step to
654         wait for the quality gate result. (default: false)
655     :stream: Keyword that represents a release code-name.
656         Often the same as the branch. (default: master)
657     :submodule-recursive: Whether to checkout submodules recursively.
658         (default: true)
659     :submodule-timeout: Timeout (in minutes) for checkout operation.
660         (default: 10)
661     :submodule-disable: Disable submodule checkout operation.
662         (default: false)
663     :scan-dev-branch: Run the scan on a developer branch.
664         (default: true)
665
666     :gerrit_sonar_triggers: Override Gerrit Triggers.
667
668
669 SonarCloud Example:
670
671 .. literalinclude:: ../../.jjb-test/lf-maven-jobs/maven-sonarcloud.yaml
672    :language: yaml
673
674 Maven Verify
675 ------------
676
677 Verify job which runs mvn clean install to test a project build..
678
679 :Template Names:
680
681     - {project-name}-maven-verify-{stream}-{mvn-version}-{java-version}
682     - gerrit-maven-verify
683     - github-maven-verify
684
685 :Comment Trigger: recheck|reverify
686
687 :Required parameters:
688
689     :build-node: The node to run build on.
690     :jenkins-ssh-credential: Credential to use for SSH. (Generally configured in defaults.yaml)
691     :mvn-settings: The name of settings file containing credentials for the project.
692
693 :Optional parameters:
694
695     :branch: Git branch to fetch for the build. (default: master)
696     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
697     :build-timeout: Timeout in minutes before aborting build. (default: 60)
698     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
699     :java-version: Version of Java to use for the build. (default: openjdk11)
700     :mvn-global-settings: The name of the Maven global settings to use for
701         Maven configuration. (default: global-settings)
702     :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '')
703     :mvn-params: Parameters to pass to the mvn CLI. (default: '')
704     :mvn-version: Version of maven to use. (default: mvn35)
705     :stream: Keyword that represents a release code-name.
706         Often the same as the branch. (default: master)
707     :submodule-recursive: Whether to checkout submodules recursively.
708         (default: true)
709     :submodule-timeout: Timeout (in minutes) for checkout operation.
710         (default: 10)
711     :submodule-disable: Disable submodule checkout operation.
712         (default: false)
713
714     :gerrit_verify_triggers: Override Gerrit Triggers.
715     :gerrit_trigger_file_paths: Override file paths to filter which file
716         modifications will trigger a build.
717
718 Maven Verify for Docker
719 -----------------------
720
721 Like the Maven Verify job as described above but logs in to Docker
722 registries first. The project POM file should invoke a plugin to build
723 a Docker image. This pulls the base image from the registry in the environment
724 variable ``CONTAINER_PULL_REGISTRY``.
725
726 :Template Names:
727
728     - {project-name}-maven-docker-verify-{stream}-{mvn-version}-{java-version}
729     - gerrit-maven-docker-verify
730     - github-maven-docker-verify
731
732 :Required parameters:
733
734     :container-public-registry: Docker registry source with base images.
735
736 All other required and optional parameters are identical to the Maven Verify job
737 described above.
738
739 Maven Verify w/ Dependencies
740 ----------------------------
741
742 Verify job which runs mvn clean install to test a project build /w deps
743
744 This job's purpose is to verify a patch in conjunction to a list of upstream
745 patches it depends on. The user of this job can provide a list of patches via
746 comment trigger.
747
748 :Template Names:
749
750     - {project-name}-maven-verify-deps-{stream}-{mvn-version}-{java-version}
751     - gerrit-maven-verify-dependencies
752
753 :Comment Trigger: recheck: SPACE_SEPARATED_LIST_OF_PATCHES
754
755 :Required parameters:
756
757     :build-node: The node to run build on.
758     :jenkins-ssh-credential: Credential to use for SSH. (Generally configured in defaults.yaml)
759     :mvn-settings: The name of settings file containing credentials for the project.
760
761 :Optional parameters:
762
763     :branch: Git branch to fetch for the build. (default: master)
764     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
765     :build-timeout: Timeout in minutes before aborting build. (default: 60)
766     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
767     :java-version: Version of Java to use for the build. (default: openjdk11)
768     :mvn-global-settings: The name of the Maven global settings to use for
769         Maven configuration. (default: global-settings)
770     :mvn-opts: Sets MAVEN_OPTS to start up the JVM running Maven. (default: '')
771     :mvn-params: Parameters to pass to the mvn CLI. (default: '')
772     :mvn-version: Version of maven to use. (default: mvn35)
773     :stream: Keyword that represents a release code-name.
774         Often the same as the branch. (default: master)
775     :submodule-recursive: Whether to checkout submodules recursively.
776         (default: true)
777     :submodule-timeout: Timeout (in minutes) for checkout operation.
778         (default: 10)
779     :submodule-disable: Disable submodule checkout operation.
780         (default: false)
781
782     :gerrit_verify_triggers: Override Gerrit Triggers.
783     :gerrit_trigger_file_paths: Override file paths to filter which file
784         modifications will trigger a build.