Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d3f226d
Add rootless support
lroubeyrie-ingenico Dec 24, 2024
88284a2
Clarifying password masking in `RegistryEndpointStepTest`
jglick Nov 1, 2024
a5fb32f
Use `jenkins.baseline` to reduce bom update mistakes (#328)
strangelookingnerd Jan 17, 2025
b784223
Require 2.452.4 and fix build (#327)
jonesbusy Jan 17, 2025
43d9e39
Revive test suite on Linux (#330)
basil Jan 18, 2025
1b97552
[JENKINS-75102] Fix Windows Docker running Windows container with spa…
MarkRx Jan 20, 2025
9f1071e
Revive test suite on Windows (#331)
basil Jan 20, 2025
5278946
Migrate from EE 8 to EE 9 (#329)
basil Feb 12, 2025
a1bf219
Bump org.jenkins-ci.plugins:plugin from 5.5 to 5.7 (#334)
dependabot[bot] Feb 12, 2025
12aac2d
Use `docker ps` to detect absence of docker permissions (#336)
MarkEWaite Feb 18, 2025
6568353
Avoid excessive `Closure`s
jglick Feb 25, 2025
be8f3bf
`void` return type was incorrect (but CPS-transformed code does not c…
jglick Feb 25, 2025
6f080c0
Skip `agentDockerWithCreds` unless both `docker.username` and `docker…
jglick Feb 26, 2025
927209f
Deleting `agentDockerWithCreds` test
jglick Feb 27, 2025
1372ed1
Compatibility for `DockerPipelineScript`
jglick Mar 3, 2025
4a503ed
Dep released
jglick Mar 4, 2025
89f0181
Make extension optional so it will be easier to delete the API later
jglick Mar 4, 2025
4aeeef3
Suppressing `DockerAgentTest.userHandbookDockerfile` in CI
jglick Mar 4, 2025
66f6e22
Bump org.jenkins-ci.plugins:plugin from 5.7 to 5.9 (#344)
dependabot[bot] Mar 14, 2025
72a65cc
Bump io.jenkins.tools.bom:bom-2.479.x from 4228.v0a_71308d905b_ to 44…
dependabot[bot] Mar 24, 2025
0206b2a
Bump org.jenkins-ci.plugins:plugin from 5.9 to 5.12
dependabot[bot] May 1, 2025
e24684f
[JENKINS-75679] Reproduced `FilePathPickle` usage in test
jglick May 28, 2025
63f6900
More compelling test, using a containerized agent
jglick May 29, 2025
7ac264b
Fixed using `KeyMaterial2`
jglick May 29, 2025
f3cfea9
`DockerDSLTest.firstDoNoHarm` flaky just like https://github.com/jenk…
jglick May 29, 2025
86f1bde
Dep released
jglick May 30, 2025
d005a70
Bump org.jenkins-ci.plugins:plugin from 5.12 to 5.18 (#358)
dependabot[bot] Jul 10, 2025
fa2f5ea
Bump org.testcontainers:testcontainers from 1.21.0 to 1.21.3 (#357)
dependabot[bot] Jul 10, 2025
6d81b0c
Bump io.jenkins.tools.bom:bom-2.479.x from 4488.v7fe26526366e to 4969…
dependabot[bot] Jul 10, 2025
d8bf5e5
Add userns=keep-id option for podman
lroubeyrie-ingenico Jul 18, 2025
7dec078
Merge branch 'jenkinsci:master' into feature/rootless_mode
lnlrbr Jul 21, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,16 @@
}

String command = launcher.isUnix() ? "cat" : "cmd.exe";
container = dockerClient.run(env, step.image, step.args, ws, volumes, volumesFromContainers, envReduced, dockerClient.whoAmI(), /* expected to hang until killed */ command);
String whoAmI = dockerClient.whoAmI();
if (dockerClient.isRootless()) {

Check warning on line 201 in src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 201 is only partially covered, one branch is missing
listener.getLogger().println("Running in rootless mode.");
whoAmI = "";
if (dockerClient.getEngine().equals("podman")) {
listener.getLogger().println("Podman detected.");
step.args = step.args == null ? "--userns=keep-id" : "--userns=keep-id " + step.args;

Check warning on line 206 in src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 202-206 are not covered by tests
}
}
container = dockerClient.run(env, step.image, step.args, ws, volumes, volumesFromContainers, envReduced, whoAmI, /* expected to hang until killed */ command);
final List<String> ps = dockerClient.listProcess(env, container);
if (!ps.contains(command)) {
listener.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.Node;
import hudson.model.TaskListener;
import hudson.util.ArgumentListBuilder;
import hudson.util.VersionNumber;
import java.io.BufferedReader;
Expand Down Expand Up @@ -318,6 +319,12 @@
return result;
}

private String executeCommand(String... command) throws IOException, InterruptedException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
launcher.launch().cmds(command).quiet(true).stdout(output).start().joinWithTimeout(CLIENT_TIMEOUT, TimeUnit.SECONDS, launcher.getListener());
return output.toString(Charset.defaultCharset()).trim();
}

/**
* Who is executing this {@link DockerClient} instance.
*
Expand All @@ -328,15 +335,34 @@
// Windows does not support username
return "";
}
ByteArrayOutputStream userId = new ByteArrayOutputStream();
launcher.launch().cmds("id", "-u").quiet(true).stdout(userId).start().joinWithTimeout(CLIENT_TIMEOUT, TimeUnit.SECONDS, launcher.getListener());

ByteArrayOutputStream groupId = new ByteArrayOutputStream();
launcher.launch().cmds("id", "-g").quiet(true).stdout(groupId).start().joinWithTimeout(CLIENT_TIMEOUT, TimeUnit.SECONDS, launcher.getListener());
String userId = executeCommand("id", "-u");
String groupId = executeCommand("id", "-g");

final String charsetName = Charset.defaultCharset().name();
return String.format("%s:%s", userId.toString(charsetName).trim(), groupId.toString(charsetName).trim());
return String.format("%s:%s", userId, groupId);
}

public String getEngine() throws IOException, InterruptedException {

String engine = "docker";

String cmd = executeCommand("docker", "--version");
if (cmd.toLowerCase().contains("podman")) {

Check warning on line 350 in src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 350 is only partially covered, one branch is missing
engine = "podman";

Check warning on line 351 in src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 351 is not covered by tests
}
else {
String rootless = executeCommand("docker", "info", "-f", "{{.SecurityOptions}}" );
if (rootless.toLowerCase().contains("rootless")) {

Check warning on line 355 in src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 355 is only partially covered, one branch is missing
engine = "docker-rootless";

Check warning on line 356 in src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 356 is not covered by tests
}
}

return engine;
}

public boolean isRootless() throws IOException, InterruptedException {
String engine = getEngine();
return engine.equals("docker-rootless") || engine.equals("podman");

Check warning on line 365 in src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 365 is only partially covered, 2 branches are missing
}

private static final Pattern hostnameMount = Pattern.compile("/containers/([a-z0-9]{64})/hostname");
Expand Down