update Jenkinsfile

This commit is contained in:
Alastair Smith 2019-03-04 11:24:47 -06:00
parent 85c7931b3f
commit aee0abf88c
1 changed files with 39 additions and 74 deletions

113
Jenkinsfile vendored
View File

@ -9,84 +9,49 @@ pipeline {
timeout(time: 1, unit: 'HOURS') timeout(time: 1, unit: 'HOURS')
} }
stages { stages {
stage( 'docker.github.io' ) { stage( 'docs-private' ) {
agent { agent {
label 'ubuntu-1604-aufs-stable' label 'ubuntu-1604-aufs-stable'
} }
stages {
stage( 'build and push stage image' ) {
when {
branch 'master'
}
steps { steps {
withDockerRegistry(reg) { sh 'printenv'
sh """ }
docker image build --tag docs/docker.github.io:stage-${env.BUILD_NUMBER} . && \ // stages {
docker image push docs/docker.github.io:stage-${env.BUILD_NUMBER} // stage( 'build and push image' ) {
""" // when {
} // branch 'master'
} // }
} // steps {
stage( 'build and push prod image' ) { // withDockerRegistry(reg) {
when { // sh """
branch 'published' // docker image build --tag docs/docs-private:build-${env.BUILD_NUMBER} . && \
} // docker image push docs/docs-private:build-${env.BUILD_NUMBER}
steps { // """
withDockerRegistry(reg) { // }
sh """ // }
docker image build --tag docs/docker.github.io:prod-${env.BUILD_NUMBER} . && \ // }
docker image push docs/docker.github.io:prod-${env.BUILD_NUMBER} // stage( 'update service' ) {
""" // when {
} // branch 'master'
} // }
} // steps {
stage( 'update docs-stage' ) { // withVpn(dtrVpnAddress) {
when { // withCredentials(ucpBundle) {
branch 'master' // sh 'unzip -o $UCP'
} // }
steps { // withDockerRegistry(reg) {
withVpn(dtrVpnAddress) { // sh """
withCredentials(ucpBundle) { // export DOCKER_TLS_VERIFY=1
sh 'unzip -o $UCP' // export COMPOSE_TLS_VERSION=TLSv1_2
} // export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
withDockerRegistry(reg) { // export DOCKER_HOST=tcp://ucp.corp-us-east-1.aws.dckr.io:443
sh """ // docker service update --detach=false --force --image docs/docs-private:build-${env.BUILD_NUMBER} docs-beta-docker-com_docs --with-registry-auth
export DOCKER_TLS_VERIFY=1 // """
export COMPOSE_TLS_VERSION=TLSv1_2 // }
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot // }
export DOCKER_HOST=tcp://ucp.corp-us-east-1.aws.dckr.io:443 // }
docker service update --detach=false --force --image docs/docker.github.io:stage-${env.BUILD_NUMBER} docs-stage-docker-com_docs --with-registry-auth // }
""" // }
}
}
}
}
stage( 'update docs-prod' ) {
when {
branch 'published'
}
steps {
withVpn(dtrVpnAddress) {
withCredentials(ucpBundle) {
sh 'unzip -o $UCP'
}
withCredentials(slackString) {
withDockerRegistry(reg) {
sh """
cd ucp-bundle-success_bot
export DOCKER_TLS_VERIFY=1
export COMPOSE_TLS_VERSION=TLSv1_2
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
export DOCKER_HOST=tcp://ucp.corp-us-east-1.aws.dckr.io:443
docker service update --detach=false --force --image docs/docker.github.io:prod-${env.BUILD_NUMBER} docs-docker-com_docs --with-registry-auth
curl -X POST -H 'Content-type: application/json' --data '{"text":"Successfully published docs. https://docs.docker.com/"}' $slack
"""
}
}
}
}
}
}
} }
} }
} }