Skip to content
Permalink
Browse files
[FIXED JENKINS-23343] Implement validation button for Docker URL in g…
…lobal config
  • Loading branch information
vjuranek committed Jun 7, 2014
1 parent dbf6b27 commit 6205fac97bb376f73c1551904739f281d5854eb3
Showing 2 changed files with 14 additions and 3 deletions.
@@ -12,6 +12,7 @@
import hudson.util.FormValidation;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.ServletException;
@@ -27,6 +28,7 @@

import com.kpelykh.docker.client.DockerClient;
import com.kpelykh.docker.client.DockerException;
import com.kpelykh.docker.client.model.Info;

/**
* Build step which executes various Docker commands via Docker REST API.
@@ -96,9 +98,17 @@ public DescriptorImpl() {
}
}

public FormValidation doCheckName(@QueryParameter String dockerURL) throws IOException, ServletException {
// TODO do validation
return FormValidation.ok();
public FormValidation doTestConnection(@QueryParameter String dockerUrl) throws IOException, ServletException {
LOGGER.fine("Trying to get client for " + dockerUrl);
try {
dockerClient = new DockerClient(dockerUrl);
Info info = dockerClient.info(); //TODO replace with _ping once implemented in docker client
} catch (Exception e) {
LOGGER.log(Level.WARNING, e.getMessage(), e);
return FormValidation.error("Something went wrong, cannot connect to " + dockerUrl + ", cause: "
+ e.getCause());
}
return FormValidation.ok("Connected to " + dockerUrl);
}

public boolean isApplicable(@SuppressWarnings("rawtypes") Class<? extends AbstractProject> aClass) {
@@ -4,6 +4,7 @@
<f:entry title="Docker URL" field="dockerUrl" description="Docker server REST API URL">
<f:textbox />
</f:entry>
<f:validateButton title="${%Test Connection}" progress="${%Testing...}" method="testConnection" with="dockerUrl" />
</f:section>

</j:jelly>

0 comments on commit 6205fac

Please sign in to comment.