forked from DOI-USGS/ISIS3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
209 lines (177 loc) · 11.2 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
// vim: ft=groovy
pipeline
{
agent any
stages {
stage ("CI") {
steps {
script {
def groovy_utilities = load "${pwd()}/groovy_utilities.groovy"
def isisDataPath = '/isisData/data'
def isisMgrScripts = '/isisData/data/isis3mgr_scripts'
def isisTestDataPath = "/isisData/testData"
def kakaduIncDir = "/isisData/kakadu"
def isisEnv = [
"ISIS3DATA=${isisDataPath}",
"ISIS3TESTDATA=${isisTestDataPath}",
"ISIS3MGRSCRIPTS=${isisMgrScripts}"
]
def cmakeFlags = [
"-DJP2KFLAG=ON",
"-DKAKADU_INCLUDE_DIR=${kakaduIncDir}",
"-Dpybindings=OFF",
"-DCMAKE_BUILD_TYPE=RELEASE"
]
def build_ok = true
def errors = []
def labels = ['CentOS', 'Fedora', 'Ubuntu'] // labels for Jenkins node types we will build on
def builders = [:]
for (x in labels) {
def label = x // Need to bind the label variable before the closure - can't do 'for (label in labels)'
def lower_label = x.toLowerCase()
// Create a map to pass in to the 'parallel' step so we can fire all the builds at once
builders[lower_label] = {
node(lower_label) {
stage ("${label}") {
env.STAGE_STATUS = "Checking out ISIS"
sh 'git config --global http.sslVerify false'
checkout scm
isisEnv.add("ISISROOT=${pwd()}/build")
cmakeFlags.add("-DCMAKE_INSTALL_PREFIX=${pwd()}/install")
env.STAGE_STATUS = "Creating conda environment"
sh '''
# Use the conda cache running on the Jenkins host
conda config --set channel_alias http://dmz-jenkins.wr.usgs.gov
conda config --set always_yes True
conda config --set ssl_verify false
conda create -n isis python=3
'''
if (lower_label == "centos") {
sh 'conda env update -n isis -f environment_gcc4.yml --prune'
} else {
sh 'conda env update -n isis -f environment.yml --prune'
}
withEnv(isisEnv) {
dir("${env.ISISROOT}") {
try {
env.STAGE_STATUS = "Building ISIS on ${label}"
sh """
source activate isis
cmake -GNinja ${cmakeFlags.join(' ')} ../isis
ninja -j4 install
python ../isis/scripts/isis3VarInit.py --data-dir ${env.ISIS3DATA} --test-dir ${env.ISIS3TESTDATA}
"""
}
catch(e) {
build_ok = false
errors.add(env.STAGE_STATUS)
println e.toString()
}
}
if (build_ok) {
dir("${env.ISISROOT}") {
try {
env.STAGE_STATUS = "Running unit tests on ${env.OS}"
sh """
source activate isis
echo $ISIS3TESTDATA
echo $ISIS3DATA
# environment variables
export ISISROOT=${env.ISISROOT}
export ISIS3TESTDATA="/isisData/testData"
export ISIS3DATA="/isisData/data"
export PATH=`pwd`/../install/bin:/home/jenkins/.conda/envs/isis/bin:$PATH
ctest -R _unit_ -j4 -VV
"""
}
catch(e) {
build_ok = false
echo e.toString()
}
try{
env.STAGE_STATUS = "Running app tests on ${env.OS}"
sh """
source activate isis
echo $ISIS3TESTDATA
echo $ISIS3DATA
echo $PATH
# environment variables
export ISISROOT=${env.ISISROOT}
export ISIS3TESTDATA="/isisData/testData"
export ISIS3DATA='/isisData/data'
export PATH=`pwd`/../install/bin:/home/jenkins/.conda/envs/isis/bin:$PATH
ctest -R _app_ -j4 -VV
source deactivate
"""
}
catch(e) {
build_ok = false
errors.add(env.STAGE_STATUS)
println e.toString()
}
try{
env.STAGE_STATUS = "Running module tests on ${env.OS}"
sh """
source activate isis
echo $ISIS3TESTDATA
echo $ISIS3DATA
echo $PATH
# environment variables
export ISISROOT=${env.ISISROOT}
export ISIS3TESTDATA="/isisData/testData"
export ISIS3DATA='/isisData/data'
export PATH=`pwd`/../install/bin:/home/jenkins/.conda/envs/isis/bin:$PATH
ctest -R _module_ -j4 -VV
source deactivate
"""
}
catch(e) {
build_ok = false
errors.add(env.STAGE_STATUS)
println e.toString()
}
try{
env.STAGE_STATUS = "Running gtests on ${env.OS}"
sh """
source activate isis
echo $ISIS3TESTDATA
echo $ISIS3DATA
echo $PATH
# environment variables
export ISISROOT=${env.ISISROOT}
export ISIS3TESTDATA="/isisData/testData"
export ISIS3DATA='/isisData/data'
export PATH=`pwd`/../install/bin:/home/jenkins/.conda/envs/isis/bin:$PATH
ctest -R "." -E "(_app_|_unit_|_module_)" -j4 -VV
source deactivate
"""
}
catch(e) {
build_ok = false
errors.add(env.STAGE_STATUS)
println e.toString()
}
}
}
if(build_ok) {
currentBuild.result = "SUCCESS"
}
else {
currentBuild.result = "FAILURE"
def comment = "Failed during:\n"
errors.each {
comment += "- ${it}\n"
}
groovy_utilities.setGitHubBuildStatus(comment)
}
}
}
}
}
}
parallel builders
}
}
}
}
}