The default preparation stage takes care about the basic job setup needed to build the project:
- initialize needed build tools
- checkout from scm
- set the build name to a meaning name
- delete project artifacts from local maven repository
At first the tools needed for the maven build are initialized by using
the setupPVTools
step.
The code will then be checked out by using the
checkoutScm
step.
After checkout the name of the build is set to a more meaningful name like
#1_origin/develop
#2_master
by using the
setBuildName
step.
Since we always want to ensure that the build always uses the latest
artifacts the project related maven artifacts are deleted from local
repository by using the using
maven.purgeSnapshots
step.
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.*
import static de.provision.devops.jenkins.pipeline.utils.ConfigConstants.*
Map config = [
(TOOLS) : [
(TOOL_JDK) : "custom-jdk-installation",
(TOOL_MAVEN) : "custom-maven-installation"
]
]
defaultPreparationStage(config)
This example will checkout develop
and master
branch from github
with the LocalBranch
extension.
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.*
import static de.provision.devops.jenkins.pipeline.utils.ConfigConstants.*
Map config = [
(SCM) : [
(SCM_URL) : "https://github.com/wcm-io/wcm-io-wcm.git",
(SCM_BRANCHES) : [[name: '*/master'], [name: '*/develop']],
(SCM_EXTENSIONS) : [[$class: 'LocalBranch']]
]
]
defaultPreparationStage(config)
This step supports the extension mechanism, so you are able to extend the step by executing code before and/or after the step is executed or even replacing the whole functionality.
💡 See _extend
for an example.
The provided configuration map object is passed to the steps that support configuration
The step itself supports the following configuration options.
All configuration options must be inside the preparationStage
(ConfigConstants.STAGE_PREPARATION
)
map element to be evaluated and used by the step.
import static de.provision.devops.jenkins.pipeline.utils.ConfigConstants.*
defaultPreparationStage(
(STAGE_PREPARATION) : [
(STAGE_PREPARATION_CHECKOUT_SCM): true,
(STAGE_PREPARATION_EXTEND) : null,
(STAGE_PREPARATION_PURGE_SHAPSHOTS): true,
(STAGE_PREPARATION_SET_BUILD_NAME): true,
(STAGE_PREPARATION_SETUP_TOOLS): true,
(STAGE_PREPARATION_STAGE_WRAP): true
]
)
Constant | ConfigConstants.STAGE_PREPARATION_EXTEND |
Type | Closure with signature (Map config, superImpl) |
Default | null |
Use this configuration option to overwrite or extend the
defaultPreparationStage
step.
Example:
import static de.provision.devops.jenkins.pipeline.utils.ConfigConstants.*
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.*
def customPreparationStage(Map config, superImpl) {
echo "before defaultPreparationStage stage"
superImpl(config)
echo "after defaultPreparationStage stage"
}
defaultCompileStage(
(STAGE_PREPARATION) : [
(STAGE_PREPARATION_EXTEND) : this.&customPreparationStage
]
)
Constant | ConfigConstants.STAGE_PREPARATION_CHECKOUT_SCM |
Type | Boolean |
Default | true |
Controls if checkout from scm is executed.
Constant | ConfigConstants.STAGE_PREPARATION_PURGE_SHAPSHOTS |
Type | Boolean |
Default | true |
Controls if maven snapshots are purged from the local repository.
Constant | ConfigConstants.STAGE_PREPARATION_SET_BUILD_NAME |
Type | Boolean |
Default | true |
Controls if build name is updated.
Constant | ConfigConstants.STAGE_PREPARATION_SETUP_TOOLS |
Type | Boolean |
Default | true |
Controls if tool setup is executed.
Constant | ConfigConstants.STAGE_PREPARATION_STAGE_WRAP |
Type | Boolean |
Default | true |
Controls if the steps are wrapped into a stage named "Preparation". Can be useful in declarative pipelines.