diff --git a/pom.xml b/pom.xml index 470f4186c..17035fc74 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 2.21 + 3.3 docker-workflow @@ -16,11 +16,11 @@ MIT License - http://opensource.org/licenses/MIT + https://opensource.org/licenses/MIT - http://wiki.jenkins-ci.org/display/JENKINS/Docker+Pipeline+Plugin + https://wiki.jenkins.io/display/JENKINS/Docker+Pipeline+Plugin scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git @@ -29,7 +29,11 @@ - 1.642.3 + 2.60.3 + 8 + 2.9 + 2.12 + 2.2 @@ -47,7 +51,7 @@ org.jenkins-ci.plugins docker-commons - 1.5 + 1.12-20180131.190257-1 org.jenkins-ci.plugins.workflow @@ -59,18 +63,43 @@ workflow-durable-task-step 2.8 + + org.jenkins-ci.plugins.workflow + workflow-basic-steps + 2.3 + + + org.jenkins-ci.plugins.workflow + workflow-api + 2.8 + + + org.jenkins-ci.plugins + script-security + 1.25 + + + org.jenkins-ci.plugins.workflow + workflow-step-api + ${workflow-step-api-plugin.version} + + + org.jenkins-ci.plugins.workflow + workflow-support + ${workflow-support-plugin.version} + org.jenkins-ci.plugins.workflow workflow-step-api + ${workflow-step-api-plugin.version} tests - 2.7 test org.jenkins-ci.plugins.workflow workflow-support + ${workflow-support-plugin.version} tests - 2.12 test @@ -79,16 +108,10 @@ 2.9 test - - org.jenkins-ci.plugins.workflow - workflow-basic-steps - 2.3 - test - org.jenkins-ci.plugins credentials-binding - 1.7 + 1.12 test diff --git a/src/main/java/org/jenkinsci/plugins/docker/workflow/RegistryEndpointStep.java b/src/main/java/org/jenkinsci/plugins/docker/workflow/RegistryEndpointStep.java index fd794d68d..d74ecfdd7 100644 --- a/src/main/java/org/jenkinsci/plugins/docker/workflow/RegistryEndpointStep.java +++ b/src/main/java/org/jenkinsci/plugins/docker/workflow/RegistryEndpointStep.java @@ -24,23 +24,29 @@ package org.jenkinsci.plugins.docker.workflow; import com.google.inject.Inject; +import hudson.EnvVars; import hudson.Extension; import hudson.FilePath; import hudson.Launcher; import hudson.model.Job; +import hudson.model.Node; import hudson.model.TaskListener; import java.io.IOException; +import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint; import org.jenkinsci.plugins.docker.commons.credentials.KeyMaterialFactory; +import org.jenkinsci.plugins.docker.commons.tools.DockerTool; import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl; import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl; import org.jenkinsci.plugins.workflow.steps.StepContextParameter; import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.DataBoundSetter; public class RegistryEndpointStep extends AbstractStepImpl { private final @Nonnull DockerRegistryEndpoint registry; + private @CheckForNull String toolName; @DataBoundConstructor public RegistryEndpointStep(@Nonnull DockerRegistryEndpoint registry) { assert registry != null; @@ -51,6 +57,14 @@ public DockerRegistryEndpoint getRegistry() { return registry; } + public String getToolName() { + return toolName; + } + + @DataBoundSetter public void setToolName(String toolName) { + this.toolName = toolName; + } + public static class Execution extends AbstractEndpointStepExecution { private static final long serialVersionUID = 1; @@ -60,9 +74,11 @@ public static class Execution extends AbstractEndpointStepExecution { @StepContextParameter private transient FilePath workspace; @StepContextParameter private transient Launcher launcher; @StepContextParameter private transient TaskListener listener; + @StepContextParameter private transient Node node; + @StepContextParameter private transient EnvVars envVars; @Override protected KeyMaterialFactory newKeyMaterialFactory() throws IOException, InterruptedException { - return step.registry.newKeyMaterialFactory(job, workspace.getChannel(), launcher, listener); + return step.registry.newKeyMaterialFactory(job, workspace, launcher, listener, DockerTool.getExecutable(step.toolName, node, listener, envVars)); } } diff --git a/src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy b/src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy index 20462d196..4d0fbc25e 100644 --- a/src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy +++ b/src/main/resources/org/jenkinsci/plugins/docker/workflow/Docker.groovy @@ -37,7 +37,7 @@ class Docker implements Serializable { public V withRegistry(String url, String credentialsId = null, Closure body) { node { script.withEnv(["DOCKER_REGISTRY_URL=${url}"]) { - script.withDockerRegistry([url: url, credentialsId: credentialsId]) { + script.withDockerRegistry(registry: [url: url, credentialsId: credentialsId], toolName: script.env.DOCKER_TOOL_NAME) { body() } } diff --git a/src/main/resources/org/jenkinsci/plugins/docker/workflow/RegistryEndpointStep/config.jelly b/src/main/resources/org/jenkinsci/plugins/docker/workflow/RegistryEndpointStep/config.jelly index 15f6a2ce9..80e08c5e9 100644 --- a/src/main/resources/org/jenkinsci/plugins/docker/workflow/RegistryEndpointStep/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/docker/workflow/RegistryEndpointStep/config.jelly @@ -25,4 +25,5 @@ THE SOFTWARE. + diff --git a/src/test/java/org/jenkinsci/plugins/docker/workflow/WithContainerStepTest.java b/src/test/java/org/jenkinsci/plugins/docker/workflow/WithContainerStepTest.java index 498f36a73..0be228408 100644 --- a/src/test/java/org/jenkinsci/plugins/docker/workflow/WithContainerStepTest.java +++ b/src/test/java/org/jenkinsci/plugins/docker/workflow/WithContainerStepTest.java @@ -25,6 +25,7 @@ import com.cloudbees.plugins.credentials.CredentialsProvider; import com.cloudbees.plugins.credentials.CredentialsScope; +import com.cloudbees.plugins.credentials.SecretBytes; import com.cloudbees.plugins.credentials.domains.Domain; import hudson.model.FileParameterValue; import hudson.model.Result; @@ -205,7 +206,7 @@ public class WithContainerStepTest { File f = tmp.newFile("some-file"); FileUtils.write(f, "some-content"); FileItem fi = new FileParameterValue.FileItemImpl(f); - FileCredentialsImpl fc = new FileCredentialsImpl(CredentialsScope.GLOBAL, "secretfile", "", fi, fi.getName(), null); + FileCredentialsImpl fc = new FileCredentialsImpl(CredentialsScope.GLOBAL, "secretfile", "", fi, fi.getName(), (SecretBytes) null); CredentialsProvider.lookupStores(story.j.jenkins).iterator().next().addCredentials(Domain.global(), fc); WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "prj"); p.setDefinition(new CpsFlowDefinition(