Skip to content
Permalink
Browse files
Add jenkinsfile for multibranch job on Jenkins
  • Loading branch information
tbouron committed Dec 5, 2019
1 parent 30f3d27 commit ae872cda08b0a5ed5662597162cd17032df9b075
Showing 2 changed files with 29 additions and 5 deletions.
@@ -30,6 +30,8 @@ RUN apt-get update && apt-get install -y \
rpm \
dpkg \
libpng-dev \
libjpeg-progs \
pngquant \
make \
automake \
autoconf \
@@ -39,6 +41,13 @@ RUN apt-get update && apt-get install -y \
nasm \
gcc

# For mvn-build
# Make sure the /.config && /.npm (for UI module builds) is writable for all users
RUN mkdir -p /.config && chmod -R 777 /.config
RUN mkdir -p /.npm && chmod -R 777 /.npm

# Make sure the /var/tmp (for RPM build) is writable for all users
RUN mkdir -p /var/tmp/ && chmod -R 777 /var/tmp/

# Make sure the /var/maven is writable for all users
RUN mkdir -p /var/maven/.m2/ && chmod -R 777 /var/maven/
ENV MAVEN_CONFIG=/var/maven/.m2
@@ -18,6 +18,21 @@
*/

node(label: 'ubuntu') {
def triggers = []
if (env.CHANGE_ID) {
triggers.push(issueCommentTrigger('.*test this please.*'))
}
if (env.BRANCH_NAME == 'master') {
triggers.push(upstream(
threshold: 'SUCCESS',
upstreamProjects: '../brooklyn-server/master, ../brooklyn-library/master, ../brooklyn-ui/master, ../brooklyn-client/master, ../brooklyn-dist/master'
))
}

properties([
pipelineTriggers(triggers)
])

catchError {
def environmentDockerImage

@@ -38,16 +53,16 @@ node(label: 'ubuntu') {
}

stage('Run tests') {
environmentDockerImage.inside('-i --rm --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') {
sh 'mvn clean install -Duser.home=/var/maven -Duser.name=jenkins'
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 --rm --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') {
sh 'mvn deploy -DskipTests -Duser.home=/var/maven -Duser.name=jenkins'
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'
}
}
}

0 comments on commit ae872cd

Please sign in to comment.