mirror of https://github.com/docker/docs.git
refactor Jenkinsfile
- use DTR images for all but docker.github.io:published - use success_bot for DTR + UCP - use environment variables instead of credentials - build and push all images inside VPN container - combine build + image and update swarm stages - remove repetitive steps / stages
This commit is contained in:
parent
9fecfbfbe4
commit
0319c1d8a9
|
@ -1,79 +1,57 @@
|
||||||
def reg = [credentialsId: 'csebuildbot', url: 'https://index.docker.io/v1/']
|
def reg = [credentialsId: 'csebuildbot', url: 'https://index.docker.io/v1/']
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent none
|
|
||||||
options {
|
|
||||||
timeout(time: 1, unit: 'HOURS')
|
|
||||||
}
|
|
||||||
stages {
|
|
||||||
stage( 'docker.github.io' ) {
|
|
||||||
agent {
|
agent {
|
||||||
label 'ubuntu-1604-aufs-stable'
|
label 'ubuntu-1604-aufs-stable'
|
||||||
}
|
}
|
||||||
environment {
|
environment {
|
||||||
DTR_VPN_ADDRESS = credentials('dtr-vpn-address')
|
DTR_VPN_ADDRESS = credentials('dtr-vpn-address')
|
||||||
|
DTR_URL = credentials('dtr-url')
|
||||||
DOCKER_HOST_STRING = credentials('docker-host')
|
DOCKER_HOST_STRING = credentials('docker-host')
|
||||||
UCP_BUNDLE = credentials('ucp-bundle')
|
UCP_BUNDLE = credentials('ucp-bundle')
|
||||||
|
SUCCESS_BOT_TOKEN = credentials('success-bot-token')
|
||||||
SLACK = credentials('slack-docs-webhook')
|
SLACK = credentials('slack-docs-webhook')
|
||||||
}
|
}
|
||||||
|
options {
|
||||||
|
timeout(time: 1, unit: 'HOURS')
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage( 'docker.github.io' ) {
|
||||||
when {
|
when {
|
||||||
expression { env.GIT_URL == 'https://github.com/Docker/docker.github.io.git' }
|
expression { env.GIT_URL == 'https://github.com/Docker/docker.github.io.git' }
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage( 'build and push stage image' ) {
|
stage( 'build + push stage image, update stage swarm' ) {
|
||||||
when {
|
|
||||||
branch 'master'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
withDockerRegistry(reg) {
|
|
||||||
sh """
|
|
||||||
docker image build --tag docs/docker.github.io:stage-${env.BUILD_NUMBER} . && \
|
|
||||||
docker image push docs/docker.github.io:stage-${env.BUILD_NUMBER}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage( 'build and push prod image' ) {
|
|
||||||
when {
|
|
||||||
branch 'published'
|
|
||||||
}
|
|
||||||
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 docs stage' ) {
|
|
||||||
when {
|
when {
|
||||||
branch 'master'
|
branch 'master'
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
withVpn("$DTR_VPN_ADDRESS") {
|
withVpn("$DTR_VPN_ADDRESS") {
|
||||||
sh "unzip -o $UCP_BUNDLE"
|
|
||||||
withDockerRegistry(reg) {
|
|
||||||
sh """
|
sh """
|
||||||
|
cat $SUCCESS_BOT_TOKEN | docker login $DTR_URL --username 'success_bot' --password-stdin
|
||||||
|
docker build -t $DTR_URL/docker/docker.github.io:stage-${env.BUILD_NUMBER} .
|
||||||
|
docker push $DTR_URL/docker/docker.github.io:stage-${env.BUILD_NUMBER}
|
||||||
|
unzip -o $UCP_BUNDLE
|
||||||
export DOCKER_TLS_VERIFY=1
|
export DOCKER_TLS_VERIFY=1
|
||||||
export COMPOSE_TLS_VERSION=TLSv1_2
|
export COMPOSE_TLS_VERSION=TLSv1_2
|
||||||
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
|
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
|
||||||
export DOCKER_HOST=$DOCKER_HOST_STRING
|
export DOCKER_HOST=$DOCKER_HOST_STRING
|
||||||
docker service update --detach=false --force --image docs/docker.github.io:stage-${env.BUILD_NUMBER} docs-stage-docker-com_docs --with-registry-auth
|
docker service update --detach=false --force --image $DTR_URL/docker/docker.github.io:stage-${env.BUILD_NUMBER} docs-stage-docker-com_docs --with-registry-auth
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
stage( 'build + push prod image, update prod swarm' ) {
|
||||||
stage( 'update docs prod' ) {
|
|
||||||
when {
|
when {
|
||||||
branch 'published'
|
branch 'published'
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
withVpn("$DTR_VPN_ADDRESS") {
|
withVpn("$DTR_VPN_ADDRESS") {
|
||||||
sh "unzip -o $UCP_BUNDLE"
|
|
||||||
withDockerRegistry(reg) {
|
withDockerRegistry(reg) {
|
||||||
sh """
|
sh """
|
||||||
|
docker build -t docs/docker.github.io:prod-${env.BUILD_NUMBER} .
|
||||||
|
docker push docs/docker.github.io:prod-${env.BUILD_NUMBER}
|
||||||
|
unzip -o $UCP_BUNDLE
|
||||||
cd ucp-bundle-success_bot
|
cd ucp-bundle-success_bot
|
||||||
export DOCKER_TLS_VERIFY=1
|
export DOCKER_TLS_VERIFY=1
|
||||||
export COMPOSE_TLS_VERSION=TLSv1_2
|
export COMPOSE_TLS_VERSION=TLSv1_2
|
||||||
|
@ -89,77 +67,46 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage( 'docs-private' ) {
|
stage( 'docs-private' ) {
|
||||||
agent {
|
|
||||||
label 'ubuntu-1604-aufs-stable'
|
|
||||||
}
|
|
||||||
environment {
|
|
||||||
DTR_VPN_ADDRESS = credentials('dtr-vpn-address')
|
|
||||||
DOCKER_HOST_STRING = credentials('docker-host')
|
|
||||||
UCP_BUNDLE = credentials('ucp-bundle')
|
|
||||||
}
|
|
||||||
when {
|
when {
|
||||||
expression { env.GIT_URL == "https://github.com/docker/docs-private.git" }
|
expression { env.GIT_URL == "https://github.com/docker/docs-private.git" }
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage( 'build and push new beta stage image' ) {
|
stage( 'build + push beta-stage image, update beta-stage swarm' ) {
|
||||||
when {
|
|
||||||
branch 'amberjack'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
withDockerRegistry(reg) {
|
|
||||||
sh """
|
|
||||||
docker image build --tag docs/docs-private:beta-stage-${env.BUILD_NUMBER} . && \
|
|
||||||
docker image push docs/docs-private:beta-stage-${env.BUILD_NUMBER}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage( 'build and push new beta image' ) {
|
|
||||||
when {
|
|
||||||
branch 'published'
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
withDockerRegistry(reg) {
|
|
||||||
sh """
|
|
||||||
docker image build --tag docs/docs-private:beta-${env.BUILD_NUMBER} . && \
|
|
||||||
docker image push docs/docs-private:beta-${env.BUILD_NUMBER}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage( 'update beta stage service' ) {
|
|
||||||
when {
|
when {
|
||||||
branch 'amberjack'
|
branch 'amberjack'
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
withVpn("$DTR_VPN_ADDRESS") {
|
withVpn("$DTR_VPN_ADDRESS") {
|
||||||
sh "unzip -o $UCP_BUNDLE"
|
|
||||||
withDockerRegistry(reg) {
|
|
||||||
sh """
|
sh """
|
||||||
|
cat $SUCCESS_BOT_TOKEN | docker login $DTR_URL --username 'success_bot' --password-stdin
|
||||||
|
docker build -t $DTR_URL/docker/docs-private:beta-stage-${env.BUILD_NUMBER} .
|
||||||
|
docker push $DTR_URL/docker/docs-private:beta-stage-${env.BUILD_NUMBER}
|
||||||
|
unzip -o $UCP_BUNDLE
|
||||||
export DOCKER_TLS_VERIFY=1
|
export DOCKER_TLS_VERIFY=1
|
||||||
export COMPOSE_TLS_VERSION=TLSv1_2
|
export COMPOSE_TLS_VERSION=TLSv1_2
|
||||||
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
|
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
|
||||||
export DOCKER_HOST=$DOCKER_HOST_STRING
|
export DOCKER_HOST=$DOCKER_HOST_STRING
|
||||||
docker service update --detach=false --force --image docs/docs-private:beta-stage-${env.BUILD_NUMBER} docs-beta-stage-docker-com_docs --with-registry-auth
|
docker service update --detach=false --force --image $DTR_URL/docker/docs-private:beta-stage-${env.BUILD_NUMBER} docs-beta-stage-docker-com_docs --with-registry-auth
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
stage( 'build + push beta image, update beta swarm' ) {
|
||||||
stage( 'update beta service' ) {
|
|
||||||
when {
|
when {
|
||||||
branch 'published'
|
branch 'published'
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
withVpn("$DTR_VPN_ADDRESS") {
|
withVpn("$DTR_VPN_ADDRESS") {
|
||||||
sh "unzip -o $UCP_BUNDLE"
|
|
||||||
withDockerRegistry(reg) {
|
|
||||||
sh """
|
sh """
|
||||||
|
cat $SUCCESS_BOT_TOKEN | docker login $DTR_URL --username 'success_bot' --password-stdin
|
||||||
|
docker build -t $DTR_URL/docker/docs-private:beta-${env.BUILD_NUMBER} .
|
||||||
|
docker push $DTR_URL/docker/docs-private:beta-${env.BUILD_NUMBER}
|
||||||
|
unzip -o $UCP_BUNDLE
|
||||||
export DOCKER_TLS_VERIFY=1
|
export DOCKER_TLS_VERIFY=1
|
||||||
export COMPOSE_TLS_VERSION=TLSv1_2
|
export COMPOSE_TLS_VERSION=TLSv1_2
|
||||||
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
|
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
|
||||||
export DOCKER_HOST=$DOCKER_HOST_STRING
|
export DOCKER_HOST=$DOCKER_HOST_STRING
|
||||||
docker service update --detach=false --force --image docs/docs-private:beta-${env.BUILD_NUMBER} docs-beta-docker-com_docs --with-registry-auth
|
docker service update --detach=false --force --image $DTR_URL/docker/docs-private:beta-${env.BUILD_NUMBER} docs-beta-docker-com_docs --with-registry-auth
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,4 +115,3 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue