Permalink
Jul 5, 2016
Aug 30, 2016
Jul 5, 2016
Aug 30, 2016
Aug 30, 2016
Jul 14, 2016
Jul 5, 2016
Aug 4, 2016
Aug 30, 2016
Newer
100644
72 lines (59 sloc)
1.82 KB

1
node {
2
stage 'Checkout'
3
4
checkout scm

5
6
stage 'Acquire util'
7
8
sh 'mkdir -p tmp'
9
dir('tmp'){
10
git([ url: "https://github.internet2.edu/docker/util.git",
11
credentialsId: "jenkins-github-access-token" ])
12
sh 'ls'
13
sh 'mv ./bin/* ../bin/.'
14
}
15
stage 'Setting build context'
16
17
def maintainer = maintainer()
18
def imagename = imagename()
19
def tag
20
21
// Tag images created on master branch with 'latest'
22
if(env.BRANCH_NAME == "master"){
23
tag = "latest"
24
}else{
25
tag = env.BRANCH_NAME
26
}
27
28
if(!imagename){
29
echo "You must define an imagename in common.bash"
30
currentBuild.result = 'FAILURE'
31
}
32
if(maintainer){
33
echo "Building ${maintainer}:${tag} for ${maintainer}"
34
}

35

42
def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}"

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

60
docker.withRegistry('https://registry.hub.docker.com/', 'dockerhub-bigfleet') {
61
def baseImg = docker.build('bigfleet/centos7base')
62
baseImg.push('latest')
63
}

65

66
def handleError(String message){
67
echo "${message}"
68
currentBuild.setResult("FAILED")
69
slackSend color: 'danger', message: "${message}"

70
//step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true])