forked from docker/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
171 lines (170 loc) · 5.77 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
def reg = [credentialsId: 'csebuildbot', url: 'https://index.docker.io/v1/']
pipeline {
agent none
options {
timeout(time: 1, unit: 'HOURS')
}
stages {
stage( 'docker.github.io' ) {
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')
SLACK = credentials('slack-docs-webhook')
}
when {
expression { env.GIT_URL == 'https://github.com/Docker/docker.github.io.git' }
}
stages {
stage( 'build and push stage image' ) {
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 {
branch 'master'
}
steps {
withVpn("$DTR_VPN_ADDRESS") {
sh "unzip -o $UCP_BUNDLE"
withDockerRegistry(reg) {
sh """
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:stage-${env.BUILD_NUMBER} docs-stage-docker-com_docs --with-registry-auth
"""
}
}
}
}
stage( 'update docs prod' ) {
when {
branch 'published'
}
steps {
withVpn("$DTR_VPN_ADDRESS") {
sh "unzip -o $UCP_BUNDLE"
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=$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' ) {
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 {
expression { env.GIT_URL == "https://github.com/docker/docs-private.git" }
}
stages {
stage( 'build and push new beta stage image' ) {
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 {
branch 'amberjack'
}
steps {
withVpn("$DTR_VPN_ADDRESS") {
sh "unzip -o $UCP_BUNDLE"
withDockerRegistry(reg) {
sh """
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/docs-private:beta-stage-${env.BUILD_NUMBER} docs-beta-stage-docker-com_docs --with-registry-auth
"""
}
}
}
}
stage( 'update beta service' ) {
when {
branch 'published'
}
steps {
withVpn("$DTR_VPN_ADDRESS") {
sh "unzip -o $UCP_BUNDLE"
withDockerRegistry(reg) {
sh """
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/docs-private:beta-${env.BUILD_NUMBER} docs-beta-docker-com_docs --with-registry-auth
"""
}
}
}
}
}
}
}
}