gradle-docker
gradle-docker copied to clipboard
Pushing just the defined tags
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 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
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.
See this PR #205 , and use dockerTagsPush task to push taged image only, dockerAllPush task to push all