forked from GeoNodeUserGroup-DE/geonode-blueprint-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeonode-extended_publish-dockerimage
69 lines (61 loc) · 2.38 KB
/
geonode-extended_publish-dockerimage
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
61
62
63
64
65
66
67
68
pipeline {
environment {
TOKEN = credentials('github-access-token')
DOCKERHUB_CREDENTIALS = 'hub.docker.com'
IMAGE_NAME = 'zalf/geonode'
GEONODE_RELEASE = "${params.GEONODE_RELEASE}"
ZALF_GEONODE_RELEASE = "${params.ZALF_GEONODE_RELEASE}"
IMAGE_TAG = "$GEONODE_RELEASE-$ZALF_GEONODE_RELEASE.$BUILD_NUMBER"
BRANCH = "${params.GEONODE_BUILD_BRANCH}"
}
agent any
stages {
stage('Building image') {
steps{
script {
dockerImage = docker.build("$IMAGE_NAME:$IMAGE_TAG", "--no-cache --build-arg GEONODE_IMAGE_VERSION=$GEONODE_RELEASE --build-arg TOKEN=$TOKEN_PSW -f docker/geonode/Dockerfile.production .")
}
}
}
stage('Push Image') {
steps {
script {
docker.withRegistry('', DOCKERHUB_CREDENTIALS ) {
dockerImage.push("$IMAGE_TAG")
dockerImage.push("$GEONODE_RELEASE")
dockerImage.push("$ZALF_GEONODE_RELEASE.$BUILD_NUMBER")
dockerImage.push('latest')
}
}
}
}
stage('Remove Unused docker image') {
steps {
sh "docker rmi $IMAGE_NAME:$IMAGE_TAG"
sh "docker rmi $IMAGE_NAME:$GEONODE_RELEASE"
sh "docker rmi $IMAGE_NAME:$ZALF_GEONODE_RELEASE.$BUILD_NUMBER"
sh "docker rmi $IMAGE_NAME:latest"
}
}
}
post {
success {
slackSend color: 'good', message: "Build ${env.JOB_NAME} ${env.BUILD_NUMBER} success (<${env.BUILD_URL}|Open Jenkins>)"
}
failure {
slackSend color: 'danger', message: "Build ${env.JOB_NAME} ${env.BUILD_NUMBER} failed (<${env.BUILD_URL}|Open Jenkins>)"
}
always {
cleanWs(cleanWhenNotBuilt: true,
cleanWhenAborted: true,
cleanWhenFailure: true,
cleanWhenSuccess: true,
cleanWhenUnstable: true,
deleteDirs: true,
disableDeferredWipeout: true,
notFailBuild: true,
patterns: [[pattern: '.gitignore', type: 'INCLUDE'],
[pattern: '.propsfile', type: 'EXCLUDE']])
}
}
}