-
Notifications
You must be signed in to change notification settings - Fork 8
/
Jenkinsfile
205 lines (205 loc) · 9.5 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
pipeline {
agent {
docker {
image 'argo.registry:5000/debian-jessie-argodoc'
}
}
options {
checkoutToSubdirectory('argodoc')
newContainerPerStage()
}
environment {
DOC_PROJECT="argodoc"
GIT_COMMITTER_NAME="newgrnetci"
GIT_COMMITTER_EMAIL="<[email protected]>"
ARGOEU_URL=sh(script: "if [ \"$env.BRANCH_NAME\" == \"master\" ]; then echo \"[email protected]:ARGOeu/argoeu.github.io.git\"; else echo \"[email protected]:argoeu-devel/argoeu-devel.github.io.git\"; fi",returnStdout: true).trim()
}
stages {
stage('Build') {
when { branch pattern: "master|devel", comparator: "REGEXP" }
parallel {
stage ('Build web-api docs'){
environment {
DOC_SOURCE="argo-web-api"
}
steps {
dir ("${WORKSPACE}/${DOC_SOURCE}") {
git branch: "${env.BRANCH_NAME}",
credentialsId: 'jenkins-rpm-repo',
url: "[email protected]:ARGOeu/${DOC_SOURCE}.git"
sh """
cd ${WORKSPACE}/${DOC_SOURCE}/doc/v2
mkdocs build --clean
cp -R ${WORKSPACE}/${DOC_SOURCE}/doc/doc/ ${WORKSPACE}/${DOC_PROJECT}/content/guides
cp -R ${WORKSPACE}/${DOC_SOURCE}/doc/v2/site/ ${WORKSPACE}/${DOC_PROJECT}/api/v2
"""
deleteDir()
}
}
}
stage ('Build messaging docs'){
environment {
DOC_SOURCE="argo-messaging"
}
steps {
dir ("${WORKSPACE}/${DOC_SOURCE}") {
git branch: "${env.BRANCH_NAME}",
credentialsId: 'jenkins-rpm-repo',
url: "[email protected]:ARGOeu/${DOC_SOURCE}.git"
sh """
cd ${WORKSPACE}/${DOC_SOURCE}/doc/v1
mkdocs build --clean
cp -R ${WORKSPACE}/${DOC_SOURCE}/doc/doc/ ${WORKSPACE}/${DOC_PROJECT}/content/guides
cp -R ${WORKSPACE}/${DOC_SOURCE}/doc/v1/site/* ${WORKSPACE}/${DOC_PROJECT}/messaging/v1
"""
deleteDir()
}
}
}
stage ('Build authn docs'){
environment {
DOC_SOURCE="argo-api-authn"
}
steps {
dir ("${WORKSPACE}/${DOC_SOURCE}") {
git branch: "${env.BRANCH_NAME}",
credentialsId: 'jenkins-rpm-repo',
url: "[email protected]:ARGOeu/${DOC_SOURCE}.git"
sh """
cd ${WORKSPACE}/${DOC_SOURCE}/docs/v1
mkdocs build --clean
cp -R ${WORKSPACE}/${DOC_SOURCE}/docs/v1/docs/ ${WORKSPACE}/${DOC_PROJECT}/content/guides
cp -R ${WORKSPACE}/${DOC_SOURCE}/docs/v1/site/* ${WORKSPACE}/${DOC_PROJECT}/authn/v1
"""
deleteDir()
}
}
}
stage ('Build poem-2 docs'){
environment {
DOC_SOURCE="poem-2"
}
steps {
dir ("${WORKSPACE}/${DOC_SOURCE}") {
git branch: "${env.BRANCH_NAME}",
credentialsId: 'jenkins-rpm-repo',
url: "[email protected]:ARGOeu/${DOC_SOURCE}.git"
sh """
cd ${WORKSPACE}/${DOC_SOURCE}/doc/v1/
mkdocs build --clean
cp -R ${WORKSPACE}/${DOC_SOURCE}/doc/v1/site/* ${WORKSPACE}/${DOC_PROJECT}/poem/v1
"""
deleteDir()
}
}
}
stage ('Build monitoring-probes docs'){
environment {
DOC_SOURCE="monitoring-probes"
}
steps {
dir ("${WORKSPACE}/${DOC_SOURCE}") {
git branch: "${env.BRANCH_NAME}",
credentialsId: 'jenkins-rpm-repo',
url: "[email protected]:ARGOeu/${DOC_SOURCE}.git"
sh """
cd ${WORKSPACE}/${DOC_SOURCE}/doc/v1/
mkdocs build --clean
cp -R ${WORKSPACE}/${DOC_SOURCE}/doc/v1/site/* ${WORKSPACE}/${DOC_PROJECT}/monitoring-probes/v1
"""
deleteDir()
}
}
}
stage ('Build argo-ams-library docs'){
environment {
DOC_SOURCE="argo-ams-library"
}
steps {
dir ("${WORKSPACE}/${DOC_SOURCE}") {
git branch: "${env.BRANCH_NAME}",
credentialsId: 'jenkins-rpm-repo',
url: "[email protected]:ARGOeu/${DOC_SOURCE}.git"
sh """
cd ${WORKSPACE}/${DOC_SOURCE}/documentation
make html
"""
}
}
}
}
}
stage('Push changes to argoeu') {
when { branch pattern: "master|devel", comparator: "REGEXP" }
steps {
echo 'Push changes...'
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-master', keyFileVariable: 'SSH_KEY')]) {
sh '''
cd $WORKSPACE/argodoc
echo ssh -i $SSH_KEY -l git -o StrictHostKeyChecking=no \\"\\$@\\" > ../local_ssh.sh
chmod +x ../local_ssh.sh
'''
withEnv(['GIT_SSH=../local_ssh.sh']) {
sh """
if [ -n "\$(git status --porcelain)" ]; then
git checkout ${env.BRANCH_NAME}
git add -A
git commit -a --author="newgrnetci <[email protected]>" -m "Update docs"
git push origin ${env.BRANCH_NAME}
rm ../local_ssh.sh
fi
"""
}
}
}
}
stage('Deploy mkdocs') {
when { branch pattern: "master|devel", comparator: "REGEXP" }
steps {
echo 'Deploying mkdocs...'
dir ("${WORKSPACE}/argoeu") {
git branch: "master",
credentialsId: 'jenkins-rpm-repo',
url: "${ARGOEU_URL}"
sh """
rm -rf ${WORKSPACE}/argoeu/api
rm -rf ${WORKSPACE}/argoeu/messaging
rm -rf ${WORKSPACE}/argoeu/authn
rm -rf ${WORKSPACE}/argoeu/poem
rm -rf ${WORKSPACE}/argoeu/monitoring-probes
rm -rf ${WORKSPACE}/argoeu/ams-library/*
cp -R ${WORKSPACE}/${DOC_PROJECT}/api ${WORKSPACE}/argoeu
cp -R ${WORKSPACE}/${DOC_PROJECT}/messaging ${WORKSPACE}/argoeu
cp -R ${WORKSPACE}/${DOC_PROJECT}/authn ${WORKSPACE}/argoeu
cp -R ${WORKSPACE}/${DOC_PROJECT}/poem ${WORKSPACE}/argoeu
cp -R ${WORKSPACE}/${DOC_PROJECT}/monitoring-probes ${WORKSPACE}/argoeu
cp -R ${WORKSPACE}/argo-ams-library/documentation/_build/html/* ${WORKSPACE}/argoeu/ams-library
cd ${WORKSPACE}/argoeu
git checkout master
"""
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-master', keyFileVariable: 'SSH_KEY')]) {
sh '''
echo ssh -i $SSH_KEY -l git -o StrictHostKeyChecking=no \\"\\$@\\" > ../local_ssh.sh
chmod +x ../local_ssh.sh
'''
withEnv(['GIT_SSH=../local_ssh.sh']) {
sh """
if [ -n "\$(git status --porcelain)" ]; then
git add -A
git commit -a --author="newgrnetci <[email protected]>" -m "Update docs"
git push origin master
fi
rm ../local_ssh.sh
"""
}
}
}
}
}
}
post {
always {
cleanWs()
}
}
}