ci: add deploy tag to commit to avoid race conditions

When parallel builds for different environments run on the same host at
the same time then the one that finishes last overwrites the Docker
image that was built first, since the commit will be the same.

"So the last shall be first, and the first last: for many be called, but few chosen."
Matthew 20:16, King James Bible

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-05-18 11:03:52 +02:00
parent d77156938a
commit 32e82c3f07
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4

3
Jenkinsfile vendored
View File

@ -63,8 +63,9 @@ pipeline {
stage('Build') { stage('Build') {
steps { script { steps { script {
dir("spiffworkflow-${params.COMPONENT}") { dir("spiffworkflow-${params.COMPONENT}") {
/* Tag and Commit is combined to avoid clashes of parallel builds. */
image = docker.build( image = docker.build(
"${params.DOCKER_NAME}:${env.GIT_COMMIT.take(8)}", "${params.DOCKER_NAME}:${params.DOCKER_TAG}-${env.GIT_COMMIT.take(8)}",
"--label=commit='${env.GIT_COMMIT.take(8)}' ." "--label=commit='${env.GIT_COMMIT.take(8)}' ."
) )
} }