Maven Jobs¶
Job Groups¶
Job groups are a great tool to configure categories of jobs together at the same time. Below the example are some starting point job-groups but we recommend creating your own to ensure that the jobs configured reflect the project’s needs.
An example project:
- job-group:
name: odl-maven-jobs
jobs:
- gerrit-maven-clm
- gerrit-maven-merge
- gerrit-maven-release
- gerrit-maven-verify
- gerrit-maven-verify-dependencies:
build-timeout: 180
mvn-version: mvn35
- project:
name: aaa
jobs:
- odl-maven-jobs
In this example we are using the job-group to assign a list of common jobs to
the aaa project. The job-group also hardcodes mvn-version
to mvn35 and
build-timeout
to 180 for all projects using this job-group.
A benefit of this method is for example disabling entire category of jobs by
modifying the job-group, insert disable-job: true
parameter
against the jobs to disable.
Below is a list of Maven job groups:
---
- job-group:
name: '{project-name}-maven-jobs'
# This job group contains all the recommended jobs that should be deployed
# for any project ci.
jobs:
- gerrit-maven-clm
- gerrit-maven-merge
- gerrit-maven-stage
- gerrit-maven-verify
- gerrit-maven-verify-dependencies
- job-group:
name: '{project-name}-github-maven-jobs'
# This job group contains all the recommended jobs that should be deployed
# for any project ci that is using github.
jobs:
- github-maven-clm
- github-maven-merge
- github-maven-stage
- github-maven-verify
- job-group:
name: '{project-name}-maven-javadoc-jobs'
# This job group contains all the recommended jobs that should be deployed
# for any project ci.
jobs:
- gerrit-maven-javadoc-publish
- gerrit-maven-javadoc-verify
- job-group:
name: '{project-name}-github-maven-javadoc-jobs'
# This job group contains all the recommended jobs that should be deployed
# for any project ci.
jobs:
- github-maven-javadoc-publish
- github-maven-javadoc-verify
Macros¶
lf-infra-maven-sonar¶
Runs Sonar against a Maven project.
Required Parameters: | |||||||
---|---|---|---|---|---|---|---|
|
lf-infra-maven-sonarcloud¶
Runs Sonar against a Maven project and pushes results to SonarCloud.
Required Parameters: | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
lf-maven-build¶
Calls the maven build script to perform a maven build.
Required parameters: | |||
---|---|---|---|
|
lf-maven-common¶
Common Jenkins configuration for Maven jobs.
lf-maven-deploy¶
Calls the maven deploy script to push artifacts to Nexus.
lf-maven-versions-plugin¶
Conditionally calls Maven versions plugin to set, update and commit the maven versions:set.
Required Parameters: | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
lf-maven-stage¶
Calls the maven stage script to push artifacts to a Nexus staging repository.
Required Parameters: | |||||||
---|---|---|---|---|---|---|---|
|
lf-update-java-alternatives¶
Setup Java alternatives for the Distro.
Required Parameters: | |||
---|---|---|---|
|
Job Templates¶
Maven CLM¶
Produces a CLM scan of the code into Nexus IQ Server.
Template Names: |
|
||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||||||||||||||
run-clm |
|||||||||||||||||||||||||||||||||||||||||||||||||
Required parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||
Optional parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Maven JavaDoc Publish¶
Produces and publishes javadocs for a Maven project.
Expects javadocs to be available in $WORKSPACE/target/site/apidocs
Template Names: |
|
||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||
remerge |
|||||||||||||||||||||||||||||||||||||
Required parameters: | |||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||
Optional parameters: | |||||||||||||||||||||||||||||||||||||
|
Maven JavaDoc Verify¶
Produces javadocs for a Maven project.
Expects javadocs to be available in $WORKSPACE/target/site/apidocs
Template Names: |
|
||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||||
recheck|reverify |
|||||||||||||||||||||||||||||||||||||||
Required parameters: | |||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||
Optional parameters: | |||||||||||||||||||||||||||||||||||||||
|
Maven Merge¶
Merge job which runs mvn clean deploy to build a project.
This job pushes files to Nexus using cURL instead of allowing the Maven deploy goal to push the upload. This is to get around the issue that Maven deploy does not properly support uploading files at the end of the build and instead pushes as it goes. There exists a -Ddeploy-at-end feature however it does not work with extensions.
This job uses the following strategy to deploy jobs to Nexus:
- wget -r to fetch maven-metadata.xml from Nexus
- mvn deploy -DaltDeploymentRepository to prepare files for upload
- Removes untouched maven-metadata.xml files before upload
- Use lftools (cURL) upload script to push artifacts to Nexus
Template Names: |
|
||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||||||||||
remerge |
|||||||||||||||||||||||||||||||||||||||||||||
Required parameters: | |||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||
Optional parameters: | |||||||||||||||||||||||||||||||||||||||||||||
|
Maven Stage¶
Produces a release candidate by creating a staging repo in Nexus.
The staging repo name is in the format PROJECT-NUMBER for example “aaa-1234”, “autorelease-2000”, “odlparent-1201”, etc…
This job runs a Maven build and deploys to $WORKSPACE/m2repo directory. This directory is then used later to deploy to Nexus.
Template Names: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Required parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
Optional parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Maven Sonar¶
Sonar job which runs mvn clean install then publishes to Sonar.
This job purposely only runs on the master branch as there are Additional configuration needed to support multiple branches and there’s not much interest in that kind of support.
Template Names: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
run-sonar |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
Required parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
Optional parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
SonarCloud Example:
---
- project:
name: example-sonarcloud
jobs:
- gerrit-maven-sonar
project: 'sonarcloud'
project-name: 'sonarcloud'
branch: 'master'
mvn-settings: 'sonarcloud-settings'
mvn-opts: '-Xmx1024m'
sonarcloud: true
sonarcloud-project-key: KEY
sonarcloud-project-organization: ORGANIZATION
sonarcloud-api-token: TOKEN
Maven Verify¶
Verify job which runs mvn clean install to test a project build..
Template Names: |
|
||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||||||
recheck|reverify |
|||||||||||||||||||||||||||||||||||||||||
Required parameters: | |||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
Optional parameters: | |||||||||||||||||||||||||||||||||||||||||
|
Maven Verify /w Dependencies¶
Verify job which runs mvn clean install to test a project build /w deps
This job can be used to verify a patch in conjunction to all of the upstream patches it depends on. The user of this job can provide a list via comment trigger.
Template Names: |
|
||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||||||
recheck: SPACE_SEPERATED_LIST_OF_PATCHES |
|||||||||||||||||||||||||||||||||||||||||
Required parameters: | |||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
Optional parameters: | |||||||||||||||||||||||||||||||||||||||||
|