Skip to content

Commit 98a5b79

Browse files
authored
Merge pull request #108 from rsandell/revert-86
[JENKINS-69432, JENKINS-69436] Revert #86 "docker login - get password from stdin"
2 parents 0d006de + bd66022 commit 98a5b79

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/org/jenkinsci/plugins/docker/commons/impl/RegistryKeyMaterialFactory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
package org.jenkinsci.plugins.docker.commons.impl;
2626

27-
import java.io.ByteArrayInputStream;
2827
import java.io.IOException;
2928
import java.net.URL;
3029
import java.nio.charset.StandardCharsets;
@@ -52,7 +51,7 @@ public class RegistryKeyMaterialFactory extends KeyMaterialFactory {
5251

5352
private static final String DOCKER_CONFIG_FILENAME = "config.json";
5453
private static final String[] BLACKLISTED_PROPERTIES = { "auths", "credsStore" };
55-
54+
5655
protected static final String DOCKER_REGISTRY_HOST_ONLY = "DOCKER_REGISTRY_HOST_ONLY";
5756

5857
private final @NonNull String username;
@@ -97,9 +96,10 @@ public KeyMaterial materialize() throws IOException, InterruptedException {
9796
}
9897

9998
try {
99+
// TODO on Docker 17.07+ use --password-stdin
100100
EnvVars envWithConfig = new EnvVars(env);
101101
envWithConfig.put("DOCKER_CONFIG", dockerConfig.getRemote());
102-
if (launcher.launch().cmds(new ArgumentListBuilder(dockerExecutable, "login", "-u", username, "--password-stdin").add(registry())).envs(envWithConfig).stdin(new ByteArrayInputStream(password.getBytes("UTF-8"))).stdout(listener).join() != 0) {
102+
if (launcher.launch().cmds(new ArgumentListBuilder(dockerExecutable, "login", "-u", username, "-p").add(password, true).add(registry())).envs(envWithConfig).stdout(listener).join() != 0) {
103103
throw new AbortException("docker login failed");
104104
}
105105
} catch (IOException | InterruptedException x) {
@@ -112,12 +112,12 @@ public KeyMaterial materialize() throws IOException, InterruptedException {
112112
}
113113
return new RegistryKeyMaterial(dockerConfig, new EnvVars("DOCKER_CONFIG", dockerConfig.getRemote()));
114114
}
115-
115+
116116
protected String registry() {
117117
if (dockerExecutable.endsWith("podman") || Boolean.parseBoolean(env.get(DOCKER_REGISTRY_HOST_ONLY, "false"))) {
118118
return endpoint.getAuthority();
119119
}
120-
120+
121121
return endpoint.toString();
122122
}
123123

0 commit comments

Comments
 (0)