Permalink
Aug 24, 2016
Aug 24, 2016
Aug 24, 2016
Sep 13, 2016
Aug 24, 2016
Aug 24, 2016
Aug 24, 2016
Sep 13, 2016
Aug 24, 2016
Aug 24, 2016
Sep 13, 2016
Aug 24, 2016
Aug 24, 2016
Sep 13, 2016
Aug 24, 2016
Newer
100644
91 lines (72 sloc)
2.14 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
}

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

30
echo "You must define an imagename in common.bash"
31
currentBuild.result = 'FAILURE'

36
37
stage 'Build'
38
try{

40
} catch(error) {
41
def error_details = readFile('./debug');

42
def message = "BUILD ERROR: There was a problem building the shibboleth-sp mage. \n\n ${error_details}"

43
sh "rm -f ./debug"
44
handleError(message)
45
}

50
stage 'Tests'
51

52
try{
53
sh 'bin/test.sh &> debug'
54
} catch(error) {
55
def error_details = readFile('./debug');
56
def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}"
57
sh "rm -f ./debug"
58
handleError(message)
59
}
60

64
65
stage 'Push'

67
def baseImg = docker.build("$maintainer/$imagename")
68
baseImg.push("$tag")
69
}

70
71
stage 'Notify'
72
73
slackSend color: 'good', message: "$maintainer/$imagename:$tag pushed to DockerHub"

74
}
75
76
def maintainer() {
77
def matcher = readFile('common.bash') =~ 'maintainer="(.+)"'
78
matcher ? matcher[0][1] : 'tier'
79
}
80
81
def imagename() {
82
def matcher = readFile('common.bash') =~ 'imagename="(.+)"'
83
matcher ? matcher[0][1] : null
84
}
85
86
def handleError(String message){
87
echo "${message}"
88
currentBuild.setResult("FAILED")
89
slackSend color: 'danger', message: "${message}"
90
sh 'exit 1'
91
}