From e462cfa0c7b043fceae74cf23fbff455bdb71ff9 Mon Sep 17 00:00:00 2001 From: Renat Date: Thu, 9 Apr 2020 11:58:42 +0200 Subject: [PATCH 1/2] DockerClient.version() falls back to trying '--version' before returning null This is added in an attempt to make this plugin compatible with podman, where '-v' does not work. --- .../plugins/docker/workflow/client/DockerClient.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java b/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java index 22e54d047..4d6a89816 100644 --- a/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java +++ b/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java @@ -251,9 +251,12 @@ public void rm(@Nonnull EnvVars launchEnv, @Nonnull String containerId) throws I LaunchResult result = launch(new EnvVars(), true, "-v"); if (result.getStatus() == 0) { return parseVersionNumber(result.getOut()); - } else { - return null; } + result = launch(new EnvVars(), true, "--version"); + if (result.getStatus() == 0) { + return parseVersionNumber(result.getOut()); + } + return null; } private static final Pattern pattern = Pattern.compile("^(\\D+)(\\d+)\\.(\\d+)\\.(\\d+)(.*)"); From ad8ae3190c11002c16d08e67be6fc44c77aa57b7 Mon Sep 17 00:00:00 2001 From: Renat Date: Sat, 1 May 2021 21:57:55 +0200 Subject: [PATCH 2/2] DockerClient.version() using only --version flag --- .../plugins/docker/workflow/client/DockerClient.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java b/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java index 4d6a89816..34dbfa1ae 100644 --- a/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java +++ b/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java @@ -248,15 +248,12 @@ public void rm(@Nonnull EnvVars launchEnv, @Nonnull String containerId) throws I * otherwise {@code null}. */ public @CheckForNull VersionNumber version() throws IOException, InterruptedException { - LaunchResult result = launch(new EnvVars(), true, "-v"); - if (result.getStatus() == 0) { - return parseVersionNumber(result.getOut()); - } - result = launch(new EnvVars(), true, "--version"); + LaunchResult result = launch(new EnvVars(), true, "--version"); if (result.getStatus() == 0) { return parseVersionNumber(result.getOut()); + } else { + return null; } - return null; } private static final Pattern pattern = Pattern.compile("^(\\D+)(\\d+)\\.(\\d+)\\.(\\d+)(.*)");