From 9243de45d88f8a44f3e1b4f3d2a3e2de80a4b24b Mon Sep 17 00:00:00 2001 From: Anton Filonenko Date: Fri, 24 Feb 2023 12:28:36 +0200 Subject: [PATCH] fix: assign a unigue build name based on commit SHA and image name --- docker.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docker.go b/docker.go index 828b9dc8..837a3f51 100644 --- a/docker.go +++ b/docker.go @@ -164,6 +164,10 @@ func (p Plugin) Exec() error { } } + // otherwise there is a possibility of parallel plugin execution in the same CI build + // resulting in different images having the same contents + setUniqueBuildName(&p.Build) + if p.Build.Squash && !p.Daemon.Experimental { fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...") p.Build.Squash = false @@ -374,6 +378,12 @@ func commandBuild(build Build) *exec.Cmd { return exec.Command(dockerExe, args...) } +func setUniqueBuildName(build *Build) { + shortenCommitSHA := build.Name[0:8] + imageName := build.Repo[strings.LastIndex(build.Repo, "/")+1 : len(build.Repo)] + build.Name = fmt.Sprintf("%s-%s", imageName, shortenCommitSHA) +} + func getSecretStringCmdArg(kvp string) (string, error) { return getSecretCmdArg(kvp, false) }