gradle-docker icon indicating copy to clipboard operation
gradle-docker copied to clipboard

Pushing just the defined tags

Open pluttrell opened this issue 7 years ago • 3 comments

Using version 0.19.2 with the following script snippet, when we run the dockerPush task we're seeing the plugin push all images, not just the version specified in tags and the latest as defined in docker.tags. Is there a way to get it to only push these two tags?

docker.name = 'mycompany/myname'

docker {
    tags project.version, 'latest'
    /* ... other items omitted for brevity ... */
}

tasks.dockerPush.dependsOn { tasks.dockerTag }

dockerPush {
    dependsOn { tasks.dockerTag }
}

pluttrell avatar Jun 13 '18 18:06 pluttrell

@pluttrell Simple solution that does not need support from the Plugin Authors, add the following to your build script:

private static String ucfirst(String str) {
        StringBuffer sb = new StringBuffer(str);
        sb.replace(0, 1, str.substring(0, 1).toUpperCase());
        return sb.toString();
    }

task dockerPublish {
  for(tag in  docker.tags)
  dependsOn "dockerPush"+ucfirst(tag)
}

now running dockerPublish should only push the tags you mentioned

kerko avatar Jul 26 '18 14:07 kerko

Just want to second this issue. I used the following configuration:

docker {
    tags "bras-test1"
    ...
}

When I ran gradle dockerPush and checked my repository after, the repository contained bras-test1, bras-test2, bras-test3, bras-test4, and bras-test, most of which were test images I'd create at a previous time.

BenedictRasmussen avatar Aug 24 '18 16:08 BenedictRasmussen

See this PR #205 , and use dockerTagsPush task to push taged image only, dockerAllPush task to push all

devkanro avatar Oct 19 '18 18:10 devkanro