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
Newer
100644
135 lines (110 sloc)
3.49 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" ])

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

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

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

81
stage 'Tests'

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

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

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

111

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