@@ -9,6 +9,11 @@ pipeline {
99 skipDefaultCheckout(true)
1010 }
1111
12+ environment {
13+ TAG = tag()
14+ BUILD_TAG = tag()
15+ }
16+
1217 stages {
1318 stage('Build') {
1419 parallel {
@@ -39,7 +44,7 @@ pipeline {
3944 }
4045 archiveArtifacts 'bin/*.tar.gz'
4146 } finally {
42- def clean_images = /docker image ls --format="{{.Repository}}:{{.Tag}}" '*$BUILD_TAG *' | xargs docker image rm -f/
47+ def clean_images = /docker image ls --format="{{.Repository}}:{{.Tag}}" '*$TAG *' | xargs docker image rm -f/
4348 sh clean_images
4449 }
4550 }
@@ -60,7 +65,7 @@ pipeline {
6065 checkout scm
6166 ansiColor('xterm') {
6267 sh 'make -f docker.Makefile save-invocation-image'
63- sh 'make -f docker.Makefile save-invocation-image-tag INVOCATION_IMAGE_TAG=$BUILD_TAG -coverage OUTPUT=coverage-invocation-image.tar'
68+ sh 'make -f docker.Makefile save-invocation-image-tag INVOCATION_IMAGE_TAG=$TAG -coverage OUTPUT=coverage-invocation-image.tar'
6469 }
6570 dir('_build') {
6671 stash name: 'invocation-image', includes: 'invocation-image.tar'
@@ -71,8 +76,8 @@ pipeline {
7176 }
7277 post {
7378 always {
74- sh 'docker rmi docker/cnab-app-base:$BUILD_TAG '
75- sh 'docker rmi docker/cnab-app-base:$BUILD_TAG -coverage'
79+ sh 'docker rmi docker/cnab-app-base:$TAG '
80+ sh 'docker rmi docker/cnab-app-base:$TAG -coverage'
7681 deleteDir()
7782 }
7883 }
@@ -98,8 +103,8 @@ pipeline {
98103 sh 'docker load -i coverage-invocation-image.tar'
99104 }
100105 ansiColor('xterm') {
101- sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG -coverage coverage-run || true'
102- sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG -coverage coverage-results'
106+ sh 'make -f docker.Makefile TAG=$TAG -coverage coverage-run || true'
107+ sh 'make -f docker.Makefile TAG=$TAG -coverage coverage-results'
103108 }
104109 archiveArtifacts '_build/ci-cov/all.out'
105110 archiveArtifacts '_build/ci-cov/coverage.html'
@@ -114,7 +119,7 @@ pipeline {
114119 archiveArtifacts '*.xml'
115120 junit '*.xml'
116121 }
117- sh 'docker rmi docker/cnab-app-base:$BUILD_TAG -coverage'
122+ sh 'docker rmi docker/cnab-app-base:$TAG -coverage'
118123 deleteDir()
119124 }
120125 }
@@ -170,7 +175,7 @@ pipeline {
170175 always {
171176 archiveArtifacts 'src/github.com/docker/app/e2e-linux.xml'
172177 junit 'src/github.com/docker/app/e2e-linux.xml'
173- sh 'docker rmi docker/cnab-app-base:$BUILD_TAG '
178+ sh 'docker rmi docker/cnab-app-base:$TAG '
174179 deleteDir()
175180 }
176181 }
@@ -205,7 +210,7 @@ pipeline {
205210 always {
206211 archiveArtifacts 'src/github.com/docker/app/e2e-darwin.xml'
207212 junit 'src/github.com/docker/app/e2e-darwin.xml'
208- sh 'docker rmi docker/cnab-app-base:$BUILD_TAG '
213+ sh 'docker rmi docker/cnab-app-base:$TAG '
209214 deleteDir()
210215 }
211216 }
@@ -240,7 +245,7 @@ pipeline {
240245 always {
241246 archiveArtifacts 'src/github.com/docker/app/e2e-windows.xml'
242247 junit 'src/github.com/docker/app/e2e-windows.xml'
243- bat 'docker rmi docker/cnab-app-base:%BUILD_TAG %'
248+ bat 'docker rmi docker/cnab-app-base:%TAG %'
244249 deleteDir()
245250 }
246251 }
@@ -273,12 +278,12 @@ pipeline {
273278 unstash 'artifacts'
274279 echo "Releasing $TAG_NAME"
275280 dir('bin') {
276- release('docker/app-cnab ')
281+ release('docker/app')
277282 }
278283 }
279284 post {
280285 always {
281- sh 'docker rmi docker/cnab-app-base:$BUILD_TAG '
286+ sh 'docker rmi docker/cnab-app-base:$TAG '
282287 deleteDir()
283288 }
284289 }
@@ -296,3 +301,11 @@ def release(repo) {
296301 sh("for f in * ; do curl -sf -H \"Authorization: token $GITHUB_TOKEN\" -H \"Accept: application/json\" -H \"Content-type: application/octet-stream\" -X POST --data-binary \"@\${f}\" $url?name=\${f}; done")
297302 }
298303}
304+
305+ def tag() {
306+ if (env.TAG_NAME != null) {
307+ return env.TAG_NAME
308+ } else {
309+ return env.BUILD_TAG
310+ }
311+ }
0 commit comments