Skip to content

Commit 5c43bbe

Browse files
rbutcherjetersen
authored andcommitted
Updated whoAmI to properly get user on Windows
1 parent 2d19156 commit 5c43bbe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/org/jenkinsci/plugins/docker/workflow/client/WindowsDockerClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ public Optional<String> getContainerIdIfContainerized() throws IOException, Inte
103103
return Optional.of(getLongIdResult.getOut());
104104
}
105105

106+
@Override
107+
public String whoAmI() throws IOException, InterruptedException {
108+
try (ByteArrayOutputStream userId = new ByteArrayOutputStream()) {
109+
launcher.launch().cmds("whoami").quiet(true).stdout(userId).start().joinWithTimeout(CLIENT_TIMEOUT, TimeUnit.SECONDS, launcher.getListener());
110+
return userId.toString();
111+
}
112+
}
113+
106114
private LaunchResult launch(EnvVars env, boolean quiet, FilePath workDir, String... args) throws IOException, InterruptedException {
107115
return launch(env, quiet, workDir, new ArgumentListBuilder(args));
108116
}

0 commit comments

Comments
 (0)