Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
51 changes: 37 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.21</version>
<version>3.3</version>
<relativePath />
</parent>
<artifactId>docker-workflow</artifactId>
Expand All @@ -16,11 +16,11 @@
<licenses>
<license>
<name>MIT License</name>
<url>http://opensource.org/licenses/MIT</url>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>

<url>http://wiki.jenkins-ci.org/display/JENKINS/Docker+Pipeline+Plugin</url>
<url>https://wiki.jenkins.io/display/JENKINS/Docker+Pipeline+Plugin</url>
<scm>
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
Expand All @@ -29,7 +29,11 @@
</scm>

<properties>
<jenkins.version>1.642.3</jenkins.version>
<jenkins.version>2.60.3</jenkins.version>
<java.level>8</java.level>
<workflow-step-api-plugin.version>2.9</workflow-step-api-plugin.version>
<workflow-support-plugin.version>2.12</workflow-support-plugin.version>
<hpi-plugin.version>2.2</hpi-plugin.version> <!-- TODO pending https://github.com/jenkinsci/plugin-pom/pull/94 -->
</properties>
<repositories>
<repository>
Expand All @@ -47,7 +51,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>docker-commons</artifactId>
<version>1.5</version>
<version>1.12-20180131.190257-1</version> <!-- TODO https://github.com/jenkinsci/docker-commons-plugin/pull/67 -->
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand All @@ -59,18 +63,43 @@
<artifactId>workflow-durable-task-step</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.25</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>${workflow-step-api-plugin.version}</version>
</dependency>
<dependency> <!-- SemaphoreStep -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>${workflow-support-plugin.version}</version>
</dependency>
<dependency> <!-- StepConfigTester -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>${workflow-step-api-plugin.version}</version>
<classifier>tests</classifier>
<version>2.7</version>
<scope>test</scope>
</dependency>
<dependency> <!-- SemaphoreStep -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>${workflow-support-plugin.version}</version>
<classifier>tests</classifier>
<version>2.12</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -79,16 +108,10 @@
<version>2.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials-binding</artifactId>
<version>1.7</version>
<version>1.12</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Docker implements Serializable {
public <V> V withRegistry(String url, String credentialsId = null, Closure<V> 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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:property field="registry"/>
<d:selectDockerTool field="toolName" xmlns:d="/lib/docker/commons"/>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down