Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 2e08324

Browse files
author
Jean-Christophe Sirot
committed
Update the Makefiles and Jenkinsfiles to prepare the release of Docker App
Fix these issues: - BUILD_ID tag was not propagated to invocation image build therefore there was a mismatch between the binary and the invocation image version. - The TAG env var was not set when building a release on Jenkins which lead to release the binaries with an incorrect version and publish the base invocation image with an invalid tag. This patch ensure that both TAG and BUILD_TAG are set to the same value. When a tag is built, TAG and BUILD_TAG are set to the name of the tag - Fix github repository name in release stage when pushing the binaries Signed-off-by: Jean-Christophe Sirot <[email protected]>
1 parent 2bd8ee1 commit 2e08324

File tree

4 files changed

+48
-26
lines changed

4 files changed

+48
-26
lines changed

Dockerfile.invocation-image

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ WORKDIR /go/src/github.com/docker/app/
1111

1212
COPY . .
1313
ARG EXPERIMENTAL="off"
14-
RUN make EXPERIMENTAL=${EXPERIMENTAL} bin/cnab-run
14+
ARG TAG="unknown"
15+
RUN make EXPERIMENTAL=${EXPERIMENTAL} BUILD_TAG=${BUILD_TAG} TAG=${TAG} bin/cnab-run
1516

1617
# local cnab invocation image
1718
FROM alpine:${ALPINE_VERSION} as invocation

Jenkinsfile

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ pipeline {
99
skipDefaultCheckout(true)
1010
}
1111

12+
environment {
13+
TAG = "${env.BUILD_TAG}"
14+
}
15+
1216
stages {
1317
stage('Build') {
1418
parallel {
@@ -78,8 +82,8 @@ pipeline {
7882
checkout scm
7983
ansiColor('xterm') {
8084
sh 'make -f docker.Makefile save-invocation-image'
81-
sh 'make -f docker.Makefile INVOCATION_IMAGE_TAG=$BUILD_TAG-coverage OUTPUT=coverage-invocation-image.tar save-invocation-image-tag'
82-
sh 'make -f docker.Makefile INVOCATION_IMAGE_TAG=$BUILD_TAG-coverage-experimental OUTPUT=coverage-experimental-invocation-image.tar save-invocation-image-tag'
85+
sh 'make -f docker.Makefile INVOCATION_IMAGE_TAG=$TAG-coverage OUTPUT=coverage-invocation-image.tar save-invocation-image-tag'
86+
sh 'make -f docker.Makefile INVOCATION_IMAGE_TAG=$TAG-coverage-experimental OUTPUT=coverage-experimental-invocation-image.tar save-invocation-image-tag'
8387
}
8488
dir('_build') {
8589
stash name: 'invocation-image', includes: 'invocation-image.tar'
@@ -91,9 +95,9 @@ pipeline {
9195
post {
9296
always {
9397
dir('src/github.com/docker/app') {
94-
sh 'docker rmi docker/cnab-app-base:$BUILD_TAG'
95-
sh 'docker rmi docker/cnab-app-base:$BUILD_TAG-coverage'
96-
sh 'docker rmi docker/cnab-app-base:$BUILD_TAG-coverage-experimental'
98+
sh 'docker rmi docker/cnab-app-base:$TAG'
99+
sh 'docker rmi docker/cnab-app-base:$TAG-coverage'
100+
sh 'docker rmi docker/cnab-app-base:$TAG-coverage-experimental'
97101
}
98102
deleteDir()
99103
}
@@ -115,8 +119,8 @@ pipeline {
115119
sh 'docker load -i coverage-invocation-image.tar'
116120
}
117121
ansiColor('xterm') {
118-
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage coverage-run || true'
119-
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage coverage-results'
122+
sh 'make -f docker.Makefile TAG=$TAG-coverage coverage-run || true'
123+
sh 'make -f docker.Makefile TAG=$TAG-coverage coverage-results'
120124
}
121125
archiveArtifacts '_build/ci-cov/all.out'
122126
archiveArtifacts '_build/ci-cov/coverage.html'
@@ -130,7 +134,7 @@ pipeline {
130134
archiveArtifacts '*.xml'
131135
junit '*.xml'
132136
}
133-
sh 'docker rmi docker/cnab-app-base:$BUILD_TAG-coverage'
137+
sh 'docker rmi docker/cnab-app-base:$TAG-coverage'
134138
deleteDir()
135139
}
136140
}
@@ -147,8 +151,8 @@ pipeline {
147151
sh 'docker load -i coverage-experimental-invocation-image.tar'
148152
}
149153
ansiColor('xterm') {
150-
sh 'make EXPERIMENTAL=on TEST_RESULTS_PREFIX="experimental-" -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage-experimental coverage-run || true'
151-
sh 'make EXPERIMENTAL=on TEST_RESULTS_PREFIX="experimental-" -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage-experimental coverage-results'
154+
sh 'make EXPERIMENTAL=on TEST_RESULTS_PREFIX="experimental-" -f docker.Makefile TAG=$TAG-coverage-experimental coverage-run || true'
155+
sh 'make EXPERIMENTAL=on TEST_RESULTS_PREFIX="experimental-" -f docker.Makefile TAG=$TAG-coverage-experimental coverage-results'
152156
}
153157
}
154158
}
@@ -160,7 +164,7 @@ pipeline {
160164
archiveArtifacts '*.xml'
161165
junit '*.xml'
162166
}
163-
sh 'docker rmi docker/cnab-app-base:$BUILD_TAG-coverage-experimental'
167+
sh 'docker rmi docker/cnab-app-base:$TAG-coverage-experimental'
164168
deleteDir()
165169
}
166170
}
@@ -217,7 +221,7 @@ pipeline {
217221
always {
218222
archiveArtifacts 'src/github.com/docker/app/e2e-linux.xml'
219223
junit 'src/github.com/docker/app/e2e-linux.xml'
220-
sh 'docker rmi docker/cnab-app-base:$BUILD_TAG'
224+
sh 'docker rmi docker/cnab-app-base:$TAG'
221225
deleteDir()
222226
}
223227
}

Jenkinsfile.baguette

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

vars.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ ifeq ($(BUILD_TAG),)
3434
BUILD_TAG := $(shell git describe --always --dirty --abbrev=10 2> $(NULL))
3535
endif
3636
ifeq ($(TAG),)
37-
TAG := $(BUILD_TAG)
37+
ifeq ($(TAG_NAME),)
38+
TAG := $(BUILD_TAG)
39+
else
40+
TAG := $(TAG_NAME)
41+
endif
3842
endif

0 commit comments

Comments
 (0)