1
0
tdlight-java-natives-linux-.../Jenkinsfile
2020-10-04 19:24:06 +02:00

109 lines
2.3 KiB
Groovy

#!/usr/bin/env groovy
// see https://jenkins.io/doc/book/pipeline/syntax/
pipeline {
environment {
MVN_SET = credentials('maven_settings')
JAVA_TOOL_OPTIONS = '-Duser.home=/var/maven'
}
agent any
triggers {
pollSCM "* * * * *"
}
options {
timestamps()
ansiColor("xterm")
}
parameters {
booleanParam(name: "RELEASE",
description: "Build a release from current commit.",
defaultValue: false)
}
stages {
stage("Setup workspace") {
steps {
sh "mkdir -p \"${workspace}/.m2\""
sh "chown 1000:1000 -R \"${workspace}/.m2\""
sh "mkdir -p \"${workspace}/.ccache\""
sh "chown 1000:1000 -R \"${workspace}/.ccache\""
sh "mkdir -p \"${workspace}/work\""
sh "chown 1000:1000 -R \"${workspace}/work\""
sh "mkdir -p \"${workspace}/output\""
sh "chown 1000:1000 -R \"${workspace}/output\""
}
}
stage("Compile C++") {
agent {
dockerfile {
dir 'jenkins/docker'
filename 'dockerfile'
additionalBuildArgs '--build-arg version=1.0.0 --build-arg UID=1000 --build-arg GID=1000 --build-arg UNAME=jenkins'
args "-v \"${workspace}/tdlight-java/src/main:/home/jenkins/output\" -v \"/var/jenkins_cache/.m2:/home/jenkins/.m2\" -v \"/var/jenkins_cache/.ccache:/home/jenkins/.ccache:rw\" -v \"${workspace}:/home/jenkins/work\""
reuseNode false
}
}
steps {
sh "./jenkins/scripts/compile.sh"
}
}
stage("Build & Deploy SNAPSHOT") {
agent {
docker {
image 'maven:3.6.3'
args '-v $HOME:/var/maven'
reuseNode true
}
}
steps {
sh "mvn -s $MVN_SET -B deploy"
}
}
stage("Release") {
agent {
docker {
image 'maven:3.6.3'
args '-v $HOME:/var/maven'
reuseNode true
}
}
when {
expression { params.RELEASE }
}
steps {
sh "mvn -s $MVN_SET -B release:prepare"
sh "mvn -s $MVN_SET -B release:perform"
}
}
stage('Deliver') {
agent {
docker {
image 'maven:3.6.3'
args '-v $HOME:/var/maven'
reuseNode true
}
}
steps {
sh './jenkins/scripts/deliver.sh'
}
}
}
post {
always {
dir("${workspace}/tdlight-java") {
deleteDir()
}
/* clean up tmp directory */
dir("${workspace}@tmp") {
deleteDir()
}
/* clean up script directory */
dir("${workspace}@script") {
deleteDir()
}
}
}
}