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 c389bbff28
commit f71cf1450e
1 changed files with 2 additions and 1 deletions

3
Jenkinsfile vendored
View File

@ -63,8 +63,9 @@ pipeline {
stage('Build') {
steps { script {
dir("spiffworkflow-${params.COMPONENT}") {
/* Tag and Commit is combined to avoid clashes of parallel builds. */
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)}' ."
)
}