forked from docker/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
117 lines (116 loc) · 4.86 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def reg = [credentialsId: 'csebuildbot', url: 'https://index.docker.io/v1/']
pipeline {
agent {
label 'ubuntu-1604-aufs-stable'
}
environment {
DTR_URL = credentials('dtr-url')
DOCKER_HOST_STRING = credentials('docker-host')
UCP_BUNDLE = credentials('ucp-bundle')
SUCCESS_BOT_TOKEN = credentials('success-bot-token')
SLACK = credentials('slack-docs-webhook')
}
options {
timeout(time: 1, unit: 'HOURS')
}
stages {
stage( 'docker.github.io' ) {
when {
expression { env.GIT_URL == 'https://github.com/Docker/docker.github.io.git' }
}
stages {
stage( 'build + push stage image, update stage swarm' ) {
when {
branch 'master'
}
steps {
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 COMPOSE_TLS_VERSION=TLSv1_2
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
export DOCKER_HOST=$DOCKER_HOST_STRING
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' ) {
when {
branch 'published'
}
steps {
withDockerRegistry(reg) {
sh """
docker build -t docs/docker.github.io:prod-${env.BUILD_NUMBER} .
docker tag docs/docker.github.io:prod-${env.BUILD_NUMBER} docs/docker.github.io:latest
docker push docs/docker.github.io:prod-${env.BUILD_NUMBER}
docker push docs/docker.github.io:latest
unzip -o $UCP_BUNDLE
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=$DOCKER_HOST_STRING
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
"""
}
}
}
}
}
stage( 'docs-private' ) {
when {
expression { env.GIT_URL == "https://github.com/docker/docs-private.git" }
}
stages {
stage( 'build + push beta-stage image, update beta-stage swarm' ) {
when {
branch 'amberjack'
}
steps {
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 COMPOSE_TLS_VERSION=TLSv1_2
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
export DOCKER_HOST=$DOCKER_HOST_STRING
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' ) {
when {
branch 'published'
}
steps {
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 COMPOSE_TLS_VERSION=TLSv1_2
export DOCKER_CERT_PATH=${WORKSPACE}/ucp-bundle-success_bot
export DOCKER_HOST=$DOCKER_HOST_STRING
docker service update --detach=false --force --image $DTR_URL/docker/docs-private:beta-${env.BUILD_NUMBER} docs-beta-docker-com_docs --with-registry-auth
"""
}
}
}
}
}
post {
unsuccessful {
sh """
curl -X POST -H 'Content-type: application/json' --data '{"text":"Error in Jenkins build. Please contact the Customer Success Engineering team for help."}' $SLACK
"""
}
}
}