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

Skip push #483

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions doc/manual/docker-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ with tag `1.5` to the registry `docker.test.org` at port
`5000`. Security information (i.e. user and password) can be specified
in multiple ways as described in section [Authentication](authentication.html).

* **skipPush** (`docker.skipPush`)
If set to `true` the plugin won't push any images that have been built.


37 changes: 21 additions & 16 deletions src/main/java/io/fabric8/maven/docker/PushMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,30 @@ public class PushMojo extends AbstractDockerMojo {
@Parameter(property = "docker.push.registry")
private String pushRegistry;

@Parameter(property="docker.skipPush", defaultValue="false")
private boolean skipPush;

/** {@inheritDoc} */
@Override
public void executeInternal(ServiceHub hub) throws DockerAccessException, MojoExecutionException {
for (ImageConfiguration imageConfig : getResolvedImages()) {
BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
String name = imageConfig.getName();
if (buildConfig != null) {
String configuredRegistry = getConfiguredRegistry(imageConfig, pushRegistry);
AuthConfig authConfig = prepareAuthConfig(new ImageName(name), configuredRegistry, true);

DockerAccess docker = hub.getDockerAccess();

long start = System.currentTimeMillis();
docker.pushImage(name, authConfig, configuredRegistry);
log.info("Pushed %s in %s", name, EnvUtil.formatDurationTill(start));

for (String tag : imageConfig.getBuildConfiguration().getTags()) {
if (tag != null) {
docker.pushImage(new ImageName(name,tag).getFullName(), authConfig, configuredRegistry);
if (!skipPush) {
for (ImageConfiguration imageConfig : getResolvedImages()) {
BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
String name = imageConfig.getName();
if (buildConfig != null) {
String configuredRegistry = getConfiguredRegistry(imageConfig, pushRegistry);
AuthConfig authConfig = prepareAuthConfig(new ImageName(name), configuredRegistry, true);

DockerAccess docker = hub.getDockerAccess();

long start = System.currentTimeMillis();
docker.pushImage(name, authConfig, configuredRegistry);
log.info("Pushed %s in %s", name, EnvUtil.formatDurationTill(start));

for (String tag : imageConfig.getBuildConfiguration().getTags()) {
if (tag != null) {
docker.pushImage(new ImageName(name, tag).getFullName(), authConfig, configuredRegistry);
}
}
}
}
Expand Down