mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 04:11:03 +00:00
Merge pull request #862 from ilbambino/master
Possibility to retag docker images
This commit is contained in:
commit
bd606c43e0
2 changed files with 9 additions and 4 deletions
|
@ -33,6 +33,7 @@ type Docker struct {
|
|||
KeepBuild bool `yaml:"keep_build"`
|
||||
Tag string `yaml:"tag"`
|
||||
Tags []string `yaml:"tags"`
|
||||
ForceTags bool `yaml:"force_tags"`
|
||||
|
||||
Condition *condition.Condition `yaml:"when,omitempty"`
|
||||
}
|
||||
|
@ -100,7 +101,11 @@ func (d *Docker) Write(f *buildfile.Buildfile) {
|
|||
// Tag and push all tags
|
||||
for _, tag := range d.Tags {
|
||||
if tag != buildImageTag {
|
||||
f.WriteCmd(fmt.Sprintf("docker tag %s:%s %s:%s", d.ImageName, buildImageTag, d.ImageName, tag))
|
||||
var options string
|
||||
if d.ForceTags {
|
||||
options = "-f"
|
||||
}
|
||||
f.WriteCmd(fmt.Sprintf("docker tag %s %s:%s %s:%s", options, d.ImageName, buildImageTag, d.ImageName, tag))
|
||||
}
|
||||
|
||||
f.WriteCmd(fmt.Sprintf("docker push %s:%s", d.ImageName, tag))
|
||||
|
|
|
@ -214,7 +214,7 @@ func TestTagsNoSingle(t *testing.T) {
|
|||
if !strings.Contains(response, "docker build --pull -t username/image:release-0.2") {
|
||||
t.Fatalf("Response: " + response + " isn't tagging images using our first custom tag\n\n")
|
||||
}
|
||||
if !strings.Contains(response, "docker tag username/image:release-0.2 username/image:release-latest") {
|
||||
if !strings.Contains(response, "docker tag username/image:release-0.2 username/image:release-latest") {
|
||||
t.Fatalf("Response: " + response + " isn't tagging images using our second custom tag\n\n")
|
||||
}
|
||||
if !strings.Contains(response, "docker push username/image:release-0.2") {
|
||||
|
@ -256,10 +256,10 @@ func TestTagsWithSingle(t *testing.T) {
|
|||
if !strings.Contains(response, "docker build --pull -t username/image:release-0.3") {
|
||||
t.Fatalf("Response: " + response + " isn't tagging images using our first custom tag\n\n")
|
||||
}
|
||||
if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-0.2") {
|
||||
if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-0.2") {
|
||||
t.Fatalf("Response: " + response + " isn't tagging images using our second custom tag\n\n")
|
||||
}
|
||||
if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-latest") {
|
||||
if !strings.Contains(response, "docker tag username/image:release-0.3 username/image:release-latest") {
|
||||
t.Fatalf("Response: " + response + " isn't tagging images using our third custom tag\n\n")
|
||||
}
|
||||
if !strings.Contains(response, "docker push username/image:release-0.2") {
|
||||
|
|
Loading…
Reference in a new issue