DATAJDBC-442 - Run Docker on Jenkins with m2 home mount.
This commit is contained in:
212
Jenkinsfile
vendored
212
Jenkinsfile
vendored
@@ -1,116 +1,118 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent none
|
agent none
|
||||||
|
|
||||||
triggers {
|
triggers {
|
||||||
pollSCM 'H/10 * * * *'
|
pollSCM 'H/10 * * * *'
|
||||||
upstream(upstreamProjects: "spring-data-commons/2.1.x", threshold: hudson.model.Result.SUCCESS)
|
upstream(upstreamProjects: "spring-data-commons/2.1.x", threshold: hudson.model.Result.SUCCESS)
|
||||||
}
|
}
|
||||||
|
|
||||||
options {
|
options {
|
||||||
disableConcurrentBuilds()
|
disableConcurrentBuilds()
|
||||||
buildDiscarder(logRotator(numToKeepStr: '14'))
|
buildDiscarder(logRotator(numToKeepStr: '14'))
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage("Test") {
|
stage("Test") {
|
||||||
when {
|
when {
|
||||||
anyOf {
|
anyOf {
|
||||||
branch '1.0.x'
|
branch '1.0.x'
|
||||||
not { triggeredBy 'UpstreamCause' }
|
not { triggeredBy 'UpstreamCause' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parallel {
|
parallel {
|
||||||
stage("test: baseline") {
|
stage("test: baseline") {
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
image 'adoptopenjdk/openjdk8:latest'
|
image 'adoptopenjdk/openjdk8:latest'
|
||||||
label 'data'
|
label 'data'
|
||||||
args '-u root -v /var/run/docker.sock:/var/run/docker.sock' // root but with no maven caching
|
args '-u root -v /var/run/docker.sock:/var/run/docker.sock'
|
||||||
}
|
// root but with no maven caching
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
}
|
||||||
steps {
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
sh 'rm -rf ?'
|
steps {
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,all-dbs clean dependency:list test -Dsort -U -B'
|
sh 'mkdir -p /tmp/jenkins-home'
|
||||||
sh "chown -R 1001:1001 target"
|
sh 'chown -R 1001:1001 .'
|
||||||
}
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,all-dbs clean dependency:list test -Dsort -U -B'
|
||||||
}
|
sh 'chown -R 1001:1001 .'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Release to artifactory') {
|
}
|
||||||
when {
|
}
|
||||||
branch 'issue/*'
|
stage('Release to artifactory') {
|
||||||
not { triggeredBy 'UpstreamCause' }
|
when {
|
||||||
}
|
anyOf {
|
||||||
agent {
|
branch '1.0.x'
|
||||||
docker {
|
not { triggeredBy 'UpstreamCause' }
|
||||||
image 'adoptopenjdk/openjdk8:latest'
|
}
|
||||||
label 'data'
|
}
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
agent {
|
||||||
}
|
docker {
|
||||||
}
|
image 'adoptopenjdk/openjdk8:latest'
|
||||||
options { timeout(time: 20, unit: 'MINUTES') }
|
label 'data'
|
||||||
|
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options { timeout(time: 20, unit: 'MINUTES') }
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
||||||
}
|
}
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
sh 'mkdir -p /tmp/jenkins-home'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,artifactory ' +
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,artifactory ' +
|
||||||
'-Dartifactory.server=https://repo.spring.io ' +
|
'-Dartifactory.server=https://repo.spring.io ' +
|
||||||
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
||||||
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
||||||
"-Dartifactory.staging-repository=libs-snapshot-local " +
|
"-Dartifactory.staging-repository=libs-snapshot-local " +
|
||||||
"-Dartifactory.build-name=spring-data-jdbc-1.0 " +
|
"-Dartifactory.build-name=spring-data-jdbc-1.0 " +
|
||||||
"-Dartifactory.build-number=${BUILD_NUMBER} " +
|
"-Dartifactory.build-number=${BUILD_NUMBER} " +
|
||||||
'-Dmaven.test.skip=true clean deploy -U -B'
|
'-Dmaven.test.skip=true clean deploy -U -B'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Release to artifactory with docs') {
|
stage('Publish documentation') {
|
||||||
when {
|
when {
|
||||||
branch '1.0.x'
|
branch '1.0.x'
|
||||||
}
|
}
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
image 'adoptopenjdk/openjdk8:latest'
|
image 'adoptopenjdk/openjdk8:latest'
|
||||||
label 'data'
|
label 'data'
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options { timeout(time: 20, unit: 'MINUTES') }
|
options { timeout(time: 20, unit: 'MINUTES') }
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
||||||
}
|
}
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
sh 'mkdir -p /tmp/jenkins-home'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,artifactory ' +
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,distribute ' +
|
||||||
'-Dartifactory.server=https://repo.spring.io ' +
|
'-Dartifactory.server=https://repo.spring.io ' +
|
||||||
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
||||||
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
||||||
"-Dartifactory.staging-repository=libs-snapshot-local " +
|
"-Dartifactory.distribution-repository=temp-private-local " +
|
||||||
"-Dartifactory.build-name=spring-data-jdbc-1.0 " +
|
'-Dmaven.test.skip=true clean deploy -U -B'
|
||||||
"-Dartifactory.build-number=${BUILD_NUMBER} " +
|
}
|
||||||
'-Dmaven.test.skip=true clean deploy -U -B'
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
post {
|
post {
|
||||||
changed {
|
changed {
|
||||||
script {
|
script {
|
||||||
slackSend(
|
slackSend(
|
||||||
color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger',
|
color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger',
|
||||||
channel: '#spring-data-dev',
|
channel: '#spring-data-dev',
|
||||||
message: "${currentBuild.fullDisplayName} - `${currentBuild.currentResult}`\n${env.BUILD_URL}")
|
message: "${currentBuild.fullDisplayName} - `${currentBuild.currentResult}`\n${env.BUILD_URL}")
|
||||||
emailext(
|
emailext(
|
||||||
subject: "[${currentBuild.fullDisplayName}] ${currentBuild.currentResult}",
|
subject: "[${currentBuild.fullDisplayName}] ${currentBuild.currentResult}",
|
||||||
mimeType: 'text/html',
|
mimeType: 'text/html',
|
||||||
recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']],
|
recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']],
|
||||||
body: "<a href=\"${env.BUILD_URL}\">${currentBuild.fullDisplayName} is reported as ${currentBuild.currentResult}</a>")
|
body: "<a href=\"${env.BUILD_URL}\">${currentBuild.fullDisplayName} is reported as ${currentBuild.currentResult}</a>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user