Skip to content
Permalink
Newer
Older
100644 74 lines (57 sloc) 1.65 KB
1
node('docker') {
Jim Van Fleet
Aug 24, 2016
2
3
stage 'Checkout'
4
5
checkout scm
6
7
stage 'Acquire util'
8
9
sh 'mkdir -p tmp'
10
dir('tmp'){
Jim Van Fleet
Aug 24, 2016
11
git([ url: "https://github.internet2.edu/docker/util.git",
12
credentialsId: "jenkins-github-access-token" ])
13
sh 'ls'
14
sh 'mv bin/* ../bin/.'
Jim Van Fleet
Aug 24, 2016
15
}
16
17
stage 'Build'
18
try{
19
def maintainer = maintainer()
20
def imagename = imagename()
21
def tag = env.BRANCH_NAME
22
if(!imagename){
23
echo "You must define an imagename in common.bash"
24
currentBuild.result = 'FAILURE'
25
}
26
if(maintainer){
27
echo "Building ${maintainer}:${tag} for ${maintainer}"
28
}
29
30
sh 'bin/build.sh &> debug'
31
} catch(error) {
32
def error_details = readFile('./debug');
33
def message = "BUILD ERROR: There was a problem building the Base Image. \n\n ${error_details}"
34
sh "rm -f ./debug"
35
handleError(message)
36
}
37
stage 'Start container'
38
39
sh 'bin/ci-run.sh'
40
Jim Van Fleet
Aug 24, 2016
41
stage 'Tests'
42
43
sh 'bin/test.sh'
44
// should build a finally construct here
45
stage 'Stop container'
46
47
sh 'bin/ci-stop.sh'
Jim Van Fleet
Aug 24, 2016
48
49
stage 'Push'
50
51
docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-bigfleet") {
Jim Van Fleet
Aug 24, 2016
52
def baseImg = docker.build("$maintainer/$imagename")
53
baseImg.push("$tag")
54
}
55
56
57
}
58
59
def maintainer() {
60
def matcher = readFile('common.bash') =~ 'maintainer="(.+)"'
61
matcher ? matcher[0][1] : 'tier'
62
}
63
64
def imagename() {
65
def matcher = readFile('common.bash') =~ 'imagename="(.+)"'
66
matcher ? matcher[0][1] : null
67
}
68
69
def handleError(String message){
70
echo "${message}"
71
currentBuild.setResult("FAILED")
72
slackSend color: 'danger', message: "${message}"
73
sh 'exit 1'
74
}
You can’t perform that action at this time.