feat: add login support to docker push.

This commit is contained in:
Ioannis Canellos
2020-02-17 21:30:51 +02:00
committed by Georgios Andrianakis
parent 297d561433
commit 084e905bce

View File

@@ -114,6 +114,13 @@ public class DockerProcessor {
}
if (pushRequested || containerImageConfig.execution == ContainerImageConfig.Execution.PUSH) {
// Check if we need to login first
if (containerImageConfig.username.isPresent() && containerImageConfig.password.isPresent()) {
boolean loginSuccesful = ExecUtil.exec("docker", "-u", containerImageConfig.username.get(), "-p" + containerImageConfig.password.get());
if (!loginSuccesful) {
throw dockerException(new String[] {"-u", containerImageConfig.username.get(), "-p", "********"});
}
}
String[] pushArgs = { "push", image };
boolean pushSuccessful = ExecUtil.exec("docker", pushArgs);
if (!pushSuccessful) {