Skip to content

Commit

Permalink
fix: assign a unigue build name based on commit SHA and image name
Browse files Browse the repository at this point in the history
  • Loading branch information
philanton committed Feb 24, 2023
1 parent f6d94e4 commit 9243de4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 9243de4

Please sign in to comment.