Permalink
Aug 24, 2016
Aug 24, 2016
Aug 24, 2016
Aug 24, 2016
Aug 24, 2016
Aug 24, 2016
Aug 24, 2016
Aug 24, 2016
Aug 24, 2016
Newer
100644
74 lines (58 sloc)
1.65 KB

2
3
stage 'Checkout'
4
5
checkout scm
6
7
stage 'Acquire util'
8

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

15
}

16
stage 'Environment'
17
18
def maintainer = maintainer()
19
def imagename = imagename()
20
def tag = env.BRANCH_NAME
21
if(!imagename){
22
echo "You must define an imagename in common.bash"
23
currentBuild.result = 'FAILURE'
24
}
25
if(maintainer){
26
echo "Building ${maintainer}:${tag} for ${maintainer}"
27
}

28
29
stage 'Build'
30
try{
31
sh 'bin/build.sh &> debug'
32
} catch(error) {
33
def error_details = readFile('./debug');
34
def message = "BUILD ERROR: There was a problem building the Base Image. \n\n ${error_details}"
35
sh "rm -f ./debug"
36
handleError(message)
37
}

42
stage 'Tests'
43
44
sh 'bin/test.sh'

45
// should build a finally construct here
46
stage 'Stop container'
47
48
sh 'bin/ci-stop.sh'

49
50
stage 'Push'

52
def baseImg = docker.build("$maintainer/$imagename")
53
baseImg.push("$tag")
54
}
55
56
57
}
58
59
def maintainer() {
60
def matcher = readFile('common.bash') =~ 'maintainer="(.+)"'
61
matcher ? matcher[0][1] : 'tier'
62
}
63
64
def imagename() {
65
def matcher = readFile('common.bash') =~ 'imagename="(.+)"'
66
matcher ? matcher[0][1] : null
67
}
68
69
def handleError(String message){
70
echo "${message}"
71
currentBuild.setResult("FAILED")
72
slackSend color: 'danger', message: "${message}"
73
sh 'exit 1'
74
}