Permalink
Newer
100644
130 lines (126 sloc)
4.31 KB
1
pipeline {
2
agent any
3
environment {
4
maintainer = "t"
5
imagename = 'm'
6
tag = 'l'
7
}
8
stages {
25
dir ('tmp') {
26
git([ url: "https://github.internet2.edu/docker/util.git", credentialsId: "jenkins-github-access-token" ])
27
sh 'ls'
28
sh 'mv bin/* ../bin/.'
40
} catch (error) {
41
def error_details = readFile('./debug')
42
def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}"
43
sh "rm -f ./debug"
44
handleError(message)
45
}
46
}
47
}
48
}
49
stage ('Test') {
50
steps {
51
script {
52
try {
58
def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}"
76
} catch (error) {
77
def error_details = readFile('./debug')
78
def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}"
79
sh "rm -f ./debug"
80
handleError(message)
81
}
82
}
83
}
84
}
90
def baseImg = docker.build("$maintainer/$imagename")
91
baseImg.push("$tag")
92
}
93
}
100
}
101
}
102
}
103
post {
104
always {
105
echo 'Done Building.'
106
}
107
failure {
108
// slackSend color: 'good', message: "Build failed"
109
handleError("BUILD ERROR: There was a problem building ${maintainer}/${imagename}:${tag}.")
116
def matcher = readFile('common.bash') =~ 'maintainer="(.+)"'
117
matcher ? matcher[0][1] : 'tier'
121
def matcher = readFile('common.bash') =~ 'imagename="(.+)"'
122
matcher ? matcher[0][1] : null
125
def handleError(String message) {
126
echo "${message}"
127
currentBuild.setResult("FAILED")
128
slackSend color: 'danger', message: "${message}"
129
sh 'exit 1'