Permalink
Newer
100644
113 lines (109 sloc)
4.02 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/.'
37
sh '(ls -l ; docker ps -a ; docker image ls ; echo Destroying ; bin/destroy.sh ; docker image ls) 2>&1 | tee debug' // temporary
38
sh './download-midpoint 2>&1 | tee -a debug'
39
sh 'bin/rebuild.sh 2>&1 | tee -a debug'
40
//sh 'echo Build output ; cat debug'
41
} catch (error) {
42
def error_details = readFile('./debug')
43
def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}"
44
sh "rm -f ./debug"
45
handleError(message)
46
}
47
}
48
}
49
}
50
stage ('Test') {
51
steps {
52
script {
53
try {
54
sh 'bin/test.sh 2>&1 | tee debug'
55
sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug'
57
sh '(echo Checking if xpath is present ; xpath || true ) 2>&1 | tee -a debug'
58
sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug'
62
def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}"
63
sh "rm -f ./debug"
64
handleError(message)
65
}
66
}
67
}
68
}
69
stage ('Push') {
70
steps {
71
script {
73
def baseImg = docker.build("$maintainer/$imagename")
74
baseImg.push("$tag")
75
}
76
}
83
}
84
}
85
}
86
post {
87
always {
88
echo 'Done Building.'
89
}
90
failure {
91
// slackSend color: 'good', message: "Build failed"
92
handleError("BUILD ERROR: There was a problem building ${maintainer}/${imagename}:${tag}.")
99
def matcher = readFile('common.bash') =~ 'maintainer="(.+)"'
100
matcher ? matcher[0][1] : 'tier'
104
def matcher = readFile('common.bash') =~ 'imagename="(.+)"'
105
matcher ? matcher[0][1] : null
108
def handleError(String message) {
109
echo "${message}"
110
currentBuild.setResult("FAILED")
111
slackSend color: 'danger', message: "${message}"
112
sh 'exit 1'