Commit d1d9ff5a authored by Patrik Dufresne's avatar Patrik Dufresne

Add Jenkins pipeline

parent f99c2ee5
pipeline {
environment {
NEXUS = credentials("local-nexus")
GITLAB = credentials("gitlab-jenkins")
}
parameters {
booleanParam(defaultValue: false, description: 'Generate a release build with a tagged version.', name: 'Release')
}
agent {
docker {
image 'jamesdbloom/docker-java7-maven'
args '-v $HOME/.m2:/root/.m2'
}
}
stages {
stage ('Setup') {
steps {
sh 'apt-get update && apt-get -qq install maven swig build-essential gcc-mingw-w64 mingw-w64 g++-multilib'
}
}
stage ('Build') {
steps {
writeFile file: "settings.xml", text: "<settings><servers><server><id>patrikdufresne</id><username>${NEXUS_USR}</username><password>${NEXUS_PSW}</password></server></servers></settings>"
sh 'mvn --settings settings.xml -U -Dmaven.test.failure.ignore=true clean deploy'
}
}
stage ('Release') {
when {
environment name: 'Release', value: 'true'
}
steps {
script {
// We want to pick up the version from the pom
pom = readMavenPom file: 'pom.xml'
version = pom.version.replace("-SNAPSHOT", "-${BUILD_NUMBER}")
}
sh 'git checkout .'
sh "mvn versions:set -DnewVersion=${version}"
sh "mvn --settings settings.xml -U -Dmaven.test.skip=true deploy"
sh """
git config --local user.email "jenkins@patrikdufresne.com"
git config --local user.name "Jenkins"
git tag 'v${version}'
export REPO=`git config remote.origin.url`
git push http://${GITLAB}@\044{REPO#*//} --tags
"""
addInfoBadge "v${version}"
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment