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
132 lines (107 sloc)
3.38 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" ])

46
47
stage 'Build haproxy'
48
49
try{
50
dir('haproxy'){
51
sh 'docker build --rm my/haproxy .'
52
}
53
} catch(error) {
54
def error_details = readFile('./debug');
55
def message = "BUILD ERROR: There was a problem building Shibboleth appliance haproxy image (${tag}). \n\n ${error_details}"
56
sh "rm -f ./debug"
57
handleError(message, tag)

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

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

80
stage 'Tests'

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

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

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

110

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

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