Permalink
Newer
100644
119 lines (114 sloc)
4.49 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/.'
30
sh "echo \"tag=\\\"${tag}\\\"\" > tag.bash ; chmod a+x tag.bash ; echo tag.bash ; cat tag.bash'
38
if (env.BRANCH_NAME == "master") {
39
toDownload = "3.9-SNAPSHOT"
40
} else {
41
toDownload = env.BRANCH_NAME
42
}
43
sh "./download-midpoint ${toDownload} 2>&1 | tee -a debug ; test \${PIPESTATUS[0]} -eq 0"
44
sh './jenkins-rebuild.sh 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' // temporary
45
} catch (error) {
46
def error_details = readFile('./debug')
47
def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}"
48
sh "rm -f ./debug"
49
handleError(message)
50
}
51
}
52
}
53
}
54
stage ('Test') {
55
steps {
56
script {
57
try {
58
sh 'echo Docker containers before root tests ; docker ps -a' // temporary
59
sh 'bin/test.sh 2>&1 | tee debug ; test ${PIPESTATUS[0]} -eq 0'
60
sh 'echo Docker containers before compositions tests ; docker ps -a' // temporary
61
62
sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0'
63
sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0'
64
sh '(cd demo/postgresql ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0'
65
sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0'
68
def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}"
79
def baseImg = docker.build("$maintainer/$imagename")
80
baseImg.push("$tag")
81
}
82
}
89
}
90
}
91
}
92
post {
93
always {
94
echo 'Done Building.'
95
}
96
failure {
97
// slackSend color: 'good', message: "Build failed"
98
handleError("BUILD ERROR: There was a problem building ${maintainer}/${imagename}:${tag}.")
105
def matcher = readFile('common.bash') =~ 'maintainer="(.+)"'
106
matcher ? matcher[0][1] : 'tier'
110
def matcher = readFile('common.bash') =~ 'imagename="(.+)"'
111
matcher ? matcher[0][1] : null
114
def handleError(String message) {
115
echo "${message}"
116
currentBuild.setResult("FAILED")
117
slackSend color: 'danger', message: "${message}"
118
sh 'exit 1'