-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
60 lines (44 loc) · 1.55 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def basename = 'hub.bccvl.org.au/jupyter/scipy-notebook';
def imgversion = env.BUILD_NUMBER;
def img = null;
def version = null;
node ('docker') {
try {
// fetch source
stage('Checkout') {
checkout scm
}
// build image
stage('Build Image') {
docker.withRegistry('https://hub.bccvl.org.au', 'hub.bccvl.org.au') {
img = docker.build("${basename}:${imgversion}")
}
// get version:
img.inside() {
version = sh(script: '/usr/bin/python3 -c \'import pkg_resources; print(pkg_resources.get_distribution("jupyterhub").version)\'',
returnStdout: true).trim()
}
// re-tag image
imgversion = version.replaceAll('\\+','_') + '-' + env.BUILD_NUMBER
img = reTagImage(img, basename, imgversion)
}
stage('Publish') {
if (currentBuild.result == null || currentBuild.result == 'SUCCESS') {
docker.withRegistry('https://hub.bccvl.org.au', 'hub.bccvl.org.au') {
img.push()
}
slackSend color: 'good', message: "New Image ${img.id}\n${env.JOB_URL}", tokenCredentialId: 'Slack_ecocloud', teamDomain: 'ecocloudgroup'
}
}
} catch (err) {
echo "Running catch"
throw err
} finally {
stage('Cleanup') {
// clean up image
if (img != null) {
sh "docker rmi ${img.id}"
}
}
}
}