Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: assign a unigue build name based on commit SHA and image name #385

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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