Permalink
Jul 27, 2016
Jul 27, 2016
Jul 27, 2016
Jul 27, 2016
Aug 9, 2016
Aug 3, 2016
Sep 12, 2016
Sep 12, 2016
Sep 12, 2016
Sep 12, 2016
Jul 27, 2016
Sep 12, 2016
Sep 12, 2016
Jul 27, 2016
Jul 27, 2016
Sep 12, 2016
Sep 12, 2016
Newer
100644
134 lines (109 sloc)
3.46 KB

3
stage 'Checkout'
4
5
checkout scm

7
stage 'Acquire util'

11
git([ url: "https://github.internet2.edu/docker/util.git",
12
credentialsId: "jenkins-github-access-token" ])

14
}

24
if(env.BRANCH_NAME == "master"){
25
tag = "latest"
26
}else{
27
tag = env.BRANCH_NAME
28
}
29

30
if(!imagename){
31
echo "You must define an imagename in common.bash"
32
currentBuild.result = 'FAILURE'

33
sh 'exit 1'
34
}
35
if(maintainer){
36
echo "Building ${imagename}:${tag} for ${maintainer}"
37
}
38
39
stage 'Acquire conftree'
40
41
sh 'mkdir -p root'
42
dir('root'){
43
git([ url: "https://github.internet2.edu/docker/shib-idp-conftree.git",
44
branch: "test", credentialsId: "jenkins-github-access-token" ])

57
def message = "BUILD ERROR: There was a problem building Shibboleth appliance haproxy image (${tag}). \n\n ${error_details}"

62
stage 'Build'
63
try{
64
sh 'bin/rebuild.sh &> debug'
65
} catch(error) {
66
def error_details = readFile('./debug');
67
def message = "BUILD ERROR: There was a problem building Shibboleth appliance image (${tag}). \n\n ${error_details}"
68
sh "rm -f ./debug"
69
handleError(message, tag)
70
}

72
stage 'Compose'
73
try{
74
sh 'bin/compose.sh &> debug'
75
} catch(error) {
76
def error_details = readFile('./debug');
77
def message = "BUILD ERROR: There was a problem composing Shibboleth appliance (${tag}). \n\n ${error_details}"
78
sh "rm -f ./debug"
79
handleError(message, tag)
80
}

82
stage 'Tests'

84
try{
85
sh 'bin/test.sh &> debug'
86
} catch(error) {
87
def error_details = readFile('./debug');
88
def message = "BUILD ERROR: There was a problem testing Shibboleth appliance :${tag}. \n\n ${error_details}"
89
sh "rm -f ./debug"
90
handleError(message, tag)
91
}

97
stage 'Notify'
98
99
slackSend color: 'good', message: "Shibboleth-appliance (${tag}) passes test battery"

100
101
}
102
103
def maintainer() {
104
def matcher = readFile('common.bash') =~ 'maintainer="(.+)"'
105
matcher ? matcher[0][1] : 'tier'
106
}
107
108
def imagename() {
109
def matcher = readFile('common.bash') =~ 'imagename="(.+)"'
110
matcher ? matcher[0][1] : null
111
}

112

113
def handleError(String message, String tag, Boolean doCleanup = true){
114
echo "${message}"
115
currentBuild.setResult("FAILED")
116
slackSend color: 'danger', message: "${message}"
117
//step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true])
118
if (doCleanup) {
119
cleanup(tag)
120
}
121
sh 'exit 1'

123
124
def cleanup(String tag) {
125
try{
126
sh 'bin/decompose.sh &> debug'
127
sh 'bin/prune.sh &> debug'
128
} catch(error) {
129
def error_details = readFile('./debug');
130
def message = "BUILD ERROR: There was a problem cleaning up Shibboleth appliance :${tag}. \n\n ${error_details}"
131
sh "rm -f ./debug"
132
handleError(message, tag, false)
133
}
134
}