forked from Substra/hlf-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
230 lines (200 loc) · 8.04 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
pipeline {
options {
timestamps ()
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '5'))
skipDefaultCheckout true
lock('substranetwork')
}
parameters {
booleanParam(name: 'WITH_NET', defaultValue: true, description: 'Launch network E2E with fixtures')
string(name: 'CHAINCODE', defaultValue: 'dev', description: 'chaincode branch')
string(name: 'BACKEND', defaultValue: 'dev', description: 'substra-backend branch')
string(name: 'CLI', defaultValue: 'dev', description: 'substra-cli branch')
}
agent none
stages {
stage('Abort previous builds'){
steps {
milestone(Integer.parseInt(env.BUILD_ID)-1)
milestone(Integer.parseInt(env.BUILD_ID))
}
}
stage('Test substra network and chaincode') {
when {
expression { return params.WITH_NET }
}
agent {
kubernetes {
label 'python'
defaultContainer 'python'
yamlFile '.cicd/agent-python.yaml'
}
}
steps {
sh """
apt update
apt install -y curl
mkdir -p /tmp/download
curl -L https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz | tar -xz -C /tmp/download
mv /tmp/download/docker/docker /usr/local/bin/
apt install -y docker-compose
"""
dir('substra-chaincode') {
checkout([
$class: 'GitSCM',
branches: [[name: "*/${params.CHAINCODE}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'substra-deploy', url: 'https://github.com/SubstraFoundation/substra-chaincode']]
])
}
sh """
rm -rf /tmp/substra/substra-chaincode
mkdir -p /tmp/substra/substra-chaincode
cp -r substra-chaincode/chaincode/* /tmp/substra/substra-chaincode/
"""
dir("substra-network") {
checkout scm
sh "pip install -r python-scripts/requirements.txt"
sh "./bootstrap.sh"
sh "export SUBSTRA_PATH=/tmp/substra/"
sh "python3 python-scripts/start.py --no-backup --fixtures --revoke --query"
}
}
post {
always {
dir("substra-network") {
sh "export SUBSTRA_PATH=/tmp/substra/"
sh "python3 python-scripts/stop.py"
}
// Verify that the start.py go well.
// Todo: improve this part
sh """
if [ -f /tmp/substra/data/log/fixtures.fail ]; then cat /tmp/substra/data/log/fixtures.log; fi
if [ -f /tmp/substra/data/log/revoke.fail ]; then cat /tmp/substra/data/log/revoke.log; fi
if [ -f /tmp/substra/data/log/run-chu-nantes.fail ]; then cat /tmp/substra/data/log/run-chu-nantes.log; fi
if [ -f /tmp/substra/data/log/run-owkin.fail ]; then cat /tmp/substra/data/log/run-owkin.log; fi
if [ -f /tmp/substra/data/log/setup-chu-nantes.fail ]; then cat /tmp/substra/data/log/setup-chu-nantes.log; fi
if [ -f /tmp/substra/data/log/setup-orderer.fail ]; then cat /tmp/substra/data/log/setup-orderer.log; fi
if [ -f /tmp/substra/data/log/setup-owkin.fail ]; then cat /tmp/substra/data/log/setup-owkin.log; fi
"""
sh "rm -rf /tmp/substra/* "
}
}
}
stage('Test substra-network, chaincode and substra backend') {
agent {
kubernetes {
label 'python'
defaultContainer 'python'
yamlFile '.cicd/agent-python.yaml'
}
}
steps {
sh """
apt update
apt install -y curl
mkdir -p /tmp/download
curl -L https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz | tar -xz -C /tmp/download
mv /tmp/download/docker/docker /usr/local/bin/
apt install -y docker-compose
"""
dir('substra-chaincode') {
checkout([
$class: 'GitSCM',
branches: [[name: "*/${params.CHAINCODE}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'substra-deploy', url: 'https://github.com/SubstraFoundation/substra-chaincode']]
])
}
sh """
rm -rf /tmp/substra/substra-chaincode
mkdir -p /tmp/substra/substra-chaincode
cp -r substra-chaincode/chaincode/* /tmp/substra/substra-chaincode/
"""
dir('substra-cli') {
checkout([
$class: 'GitSCM',
branches: [[name: "*/${params.CLI}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'substra-deploy', url: 'https://github.com/SubstraFoundation/substra-cli']]
])
}
sh """
pip install substra-cli/
pip install keyrings.alt
pip install termcolor pandas sklearn
"""
dir("substra-network") {
checkout scm
sh "pip install -r python-scripts/requirements.txt"
sh "./bootstrap.sh"
sh "export SUBSTRA_PATH=/tmp/substra/"
sh "python3 python-scripts/start.py --no-backup"
}
dir('substra-backend') {
checkout([
$class: 'GitSCM',
branches: [[name: "*/${params.BACKEND}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'substra-deploy', url: 'https://github.com/SubstraFoundation/substra-backend']]
])
sh """
python3 ./backend/node/generate_nodes.py
sh ./build-docker-images.sh
export SUBSTRA_PATH=/tmp/substra/
cd ./docker && python3 start.py -d --no-backup
sleep 120
echo \$MY_HOST_IP substra-backend.owkin.xyz >> /etc/hosts
echo \$MY_HOST_IP substra-frontend.owkin.xyz >> /etc/hosts
echo \$MY_HOST_IP substra-backend.chunantes.xyz >> /etc/hosts
echo \$MY_HOST_IP substra-frontend.chunantes.xyz >> /etc/hosts
cd ../ && python3 populate.py
"""
}
dir('substra-cli') {
sh """
cd examples/titanic
python3 -m pip install -r scripts/requirements.txt
python3 scripts/generate_data_samples.py
python3 scripts/add_dataset_objective.py
cd ../compute_plan
python3 scripts/add_compute_plan.py
python3 ../../../substra-network/python-scripts/watch_compute_plan.py compute_plan_keys.json
"""
}
}
post {
always {
dir('substra-backend') {
sh "cd ./docker; python3 stop.py"
}
dir("substra-network") {
sh "export SUBSTRA_PATH=/tmp/substra/"
sh "python3 python-scripts/stop.py"
}
// Verify that the start.py go well.
// Todo: improve this part
sh """
if [ -f /tmp/substra/data/log/fixtures.fail ]; then cat /tmp/substra/data/log/fixtures.log; fi
if [ -f /tmp/substra/data/log/revoke.fail ]; then cat /tmp/substra/data/log/revoke.log; fi
if [ -f /tmp/substra/data/log/run-chu-nantes.fail ]; then cat /tmp/substra/data/log/run-chu-nantes.log; fi
if [ -f /tmp/substra/data/log/run-owkin.fail ]; then cat /tmp/substra/data/log/run-owkin.log; fi
if [ -f /tmp/substra/data/log/setup-chu-nantes.fail ]; then cat /tmp/substra/data/log/setup-chu-nantes.log; fi
if [ -f /tmp/substra/data/log/setup-orderer.fail ]; then cat /tmp/substra/data/log/setup-orderer.log; fi
if [ -f /tmp/substra/data/log/setup-owkin.fail ]; then cat /tmp/substra/data/log/setup-owkin.log; fi
"""
sh "rm -rf /tmp/substra/* "
}
}
}
}
}