Skip to content
Permalink
Browse files
Use the .m2 folder created within the workspace between stages
This should speedup the build significantly as:
- dependencies won't be downloaded again
- artifacts should be reuse instead of compiled again
  • Loading branch information
tbouron committed Dec 4, 2019
1 parent 07de97f commit b142e430fc1c630f125eb9e360e8862d05db8291
Showing 1 changed file with 2 additions and 4 deletions.
@@ -36,20 +36,18 @@ node(label: 'ubuntu') {
}

stage('Run tests') {
environmentDockerImage.inside('-i --name brooklyn-${DOCKER_TAG} --mount type=bind,source="${HOME}/.m2/settings.xml",target=/var/maven/.m2/settings.xml,readonly -v ${WORKSPACE}:/usr/build -w /usr/build') {
environmentDockerImage.inside('-i --name brooklyn-${DOCKER_TAG} -v ${WORKSPACE}/.m2:/var/maven/.m2 --mount type=bind,source="${HOME}/.m2/settings.xml",target=/var/maven/.m2/settings.xml,readonly -v ${WORKSPACE}:/usr/build -w /usr/build') {
sh 'mvn clean install -Prpm -Pdeb -Duser.home=/var/maven -Duser.name=jenkins'
}
}

// Conditional stage to deploy artifacts, when not building a PR
if (env.CHANGE_ID == null) {
stage('Deploy artifacts') {
environmentDockerImage.inside('-i --name brooklyn-${DOCKER_TAG} --mount type=bind,source="${HOME}/.m2/settings.xml",target=/var/maven/.m2/settings.xml,readonly -v ${WORKSPACE}:/usr/build -w /usr/build') {
environmentDockerImage.inside('-i --name brooklyn-${DOCKER_TAG} -v ${WORKSPACE}/.m2:/var/maven/.m2 --mount type=bind,source="${HOME}/.m2/settings.xml",target=/var/maven/.m2/settings.xml,readonly -v ${WORKSPACE}:/usr/build -w /usr/build') {
sh 'mvn deploy -Prpm -Pdeb -DskipTests -Duser.home=/var/maven -Duser.name=jenkins'
}
}

// TODO: Publish docker image to https://hub.docker.com/r/apache/brooklyn/ ?
}
}
}

0 comments on commit b142e43

Please sign in to comment.