Skip to content

Commit 9243de4

Browse files
committed
fix: assign a unigue build name based on commit SHA and image name
1 parent f6d94e4 commit 9243de4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docker.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ func (p Plugin) Exec() error {
164164
}
165165
}
166166

167+
// otherwise there is a possibility of parallel plugin execution in the same CI build
168+
// resulting in different images having the same contents
169+
setUniqueBuildName(&p.Build)
170+
167171
if p.Build.Squash && !p.Daemon.Experimental {
168172
fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...")
169173
p.Build.Squash = false
@@ -374,6 +378,12 @@ func commandBuild(build Build) *exec.Cmd {
374378
return exec.Command(dockerExe, args...)
375379
}
376380

381+
func setUniqueBuildName(build *Build) {
382+
shortenCommitSHA := build.Name[0:8]
383+
imageName := build.Repo[strings.LastIndex(build.Repo, "/")+1 : len(build.Repo)]
384+
build.Name = fmt.Sprintf("%s-%s", imageName, shortenCommitSHA)
385+
}
386+
377387
func getSecretStringCmdArg(kvp string) (string, error) {
378388
return getSecretCmdArg(kvp, false)
379389
}

0 commit comments

Comments
 (0)