-
Notifications
You must be signed in to change notification settings - Fork 21
/
Jenkinsfile
227 lines (160 loc) · 6.54 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
pipeline {
options {
ansiColor('xterm')
}
agent {
node {
label 'bare-metal||awe'
}
}
stages {
stage('pre-cleanup') {
steps {
sh '''#!/bin/bash
set -x
base_dir=`pwd`
# Clean up
cd ${base_dir}/testing
docker-compose down
DELETE_CONTAINERS=$(docker ps -a -f name=skyport2_ -q)
if [ "${DELETE_CONTAINERS}_" != "_" ] ; then
docker rm -f ${DELETE_CONTAINERS}
fi
DELETE_CONTAINERS=$(docker ps -a -f name=compose_ -q)
if [ "${DELETE_CONTAINERS}_" != "_" ] ; then
docker rm -f ${DELETE_CONTAINERS}
fi
DELETE_CONTAINERS=$(docker ps -a -f name=awe-submitter-testing -q)
if [ "${DELETE_CONTAINERS}_" != "_" ] ; then
docker rm -f ${DELETE_CONTAINERS}
fi
echo "Deleting all data in "`pwd`
docker run --rm -v ${base_dir}:/basedir bash rm -rf /basedir/tmp /basedir/data
docker volume prune -f
echo "stage pre-cleanup done"
'''
}
}
stage('git-clone') {
steps {
sh '''#!/bin/bash
set -x
echo `pwd`
# this is needed for AWE compile scripts to determine the version number
git fetch --tags
#git pull
docker run --rm --volume `pwd`:/tmp/workspace bash rm -rf /tmp/workspace/Skyport2
git clone https://github.com/MG-RAST/Skyport2.git
rm -rf common-workflow-language
git clone https://github.com/common-workflow-language/common-workflow-language.git
echo "stage git-clone done"
'''
}
}
stage('Build') {
steps {
sh '''#!/bin/bash
set -e
echo "SHELL=$SHELL"
echo "HOSTNAME=$HOSTNAME"
export PATH="/usr/local/bin/:$PATH"
echo "PATH=$PATH"
DOCKER_PATH=$(which docker)
echo "DOCKER_PATH=${DOCKER_PATH}"
base_dir=`pwd`
echo "base_dir: ${base_dir}"
cd ${base_dir}/Skyport2
# Debugging
pwd
ls -l
# docker images
docker ps
docker ps
set -x
# Build container
cd ${base_dir}
set +x
echo Building AWE Container
set -x
#USE_CACHE="--no-cache"
USE_CACHE="" #speed-up for debugging purposes
set +e
#docker rmi mgrast/awe-server mgrast/awe-worker mgrast/awe-submitter
set -e
sleep 2
docker pull mgrast/shock
docker build ${USE_CACHE} --pull -t mgrast/awe-server .
docker build ${USE_CACHE} --pull -t mgrast/awe-worker -f Dockerfile_worker .
docker build ${USE_CACHE} --pull -t mgrast/awe-submitter -f Dockerfile_submitter .
cd ${base_dir}/testing/
docker build ${USE_CACHE} -t mgrast/awe-submitter-testing .
#cd ${base_dir}/Skyport2
#docker run --rm --volume `pwd`:/Skyport2 bash rm -rf /Skyport2/tmp
echo "docker builds complete"
sleep 5
docker run --rm mgrast/awe-server awe-server --version
docker ps
sleep 1
export SKYPORT_TMPDIR=${base_dir}/tmp
export DATADIR=${base_dir}/data
mkdir -p ${SKYPORT_TMPDIR}
mkdir -p ${DATADIR}
cd ${base_dir}/Skyport2/scripts/
source ./get_docker_binary.sh
cd ${base_dir}
set +e
rm -f ./result.xml
set -e
cd ${base_dir}/testing
docker-compose up -d
set +e
sleep 3
docker ps
docker network ls
sleep 1
echo "services started"
'''
}
}
stage('Test') {
steps {
sh '''#!/bin/bash
set -x
base_dir=`pwd`
cd $base_dir
# network name sometimes has a minus, sometimes not, depends on docker-compose version
NETWORK_NAME=$(docker network ls | grep -o "awe-\\?test_default")
echo "NETWORK_NAME: ${NETWORK_NAME}"
set +e
touch result.xml
docker run \
--rm \
--env "SHOCK_SERVER=http://shock:7445" \
--env "AWE_SERVER=http://awe-server:80" \
--network ${NETWORK_NAME} \
--name awe-submitter-testing \
--volume `pwd`/result.xml:/output/result.xml \
mgrast/awe-submitter-testing \
--junit-xml=/output/result.xml \
--timeout=120
echo "stage Test done"
'''
}
}
}
post {
always {
sh '''#!/bin/bash
set -x
# Clean up
base_dir=`pwd`
cd $base_dir/testing
docker-compose down
#docker run --rm --volume `pwd`/live-data:/live-data bash rm -rf /live-data/*
docker volume prune -f
echo "stage clean-up done"
'''
junit "result.xml"
}
}
}