Maven¶
This library allows you to perform Maven commands in a defined build agent container.
Steps¶
Step | Description |
---|---|
[dynamic]() |
Step name can be any non-reserved word. This library uses dynamic step aliasing to run the Maven phases, goals, and options defined in the step configuration. |
Configuration¶
pipeline_config.groovy
libraries {
maven {
myMavenStep {
stageName = 'Initial Maven Lifecycle'
buildContainer = 'mvn:3.8.5-openjdk-11'
phases = ['clean', 'validate']
goals = ['compiler:testCompile']
options = ['-q']
secrets {
myToken {
type = 'text'
name = 'token-name'
id = 'my-token-id'
}
myCredentials {
type = 'usernamePassword'
usernameVar = 'USER'
passwordVar = 'PASS'
id = 'my-credentials-id'
}
}
}
anotherMavenStep {
stageName = 'Maven Build'
buildContainer = 'mvn'
phases = ['build']
artifacts = ['target/*.jar']
}
}
}
Dependencies¶
- The
sdp
library - Access to an appropriate Maven build agent container via the repository defined in your
sdp
library configuration
Migrating to 4.0¶
SDP 4.0
reworked this library to use dynamic step aliasing.
The Maven tool configuration within Jenkins is no longer required to use this library.
To recreate the previous maven.run()
functionality of prior versions, the below minimal pipeline configuration and template can be used:
Sample Pipeline Configuration¶
pipeline_config.groovy
libraries {
maven {
build {
stageName = "Maven Build"
buildContainer = 'mvn'
phases = ['clean', 'install']
options = ['-P integration-test']
}
}
}
pipeline_config.groovy
libraries {
maven {
mavenId = "maven"
}
}
Sample Pipeline Template¶
Jenkinsfile
build()
Jenkinsfile
maven.run(["clean", "install"], profiles: ["integration-test"])