final String url = getUrl(build);
// Marshal the builder across the wire.
DockerClient client = getDockerClient(build);
final DockerClient.Builder builder = DockerClient.builder().fromClient(client);
BuildCommandResponse response = fpChild.act(new FilePath.FileCallable<BuildCommandResponse>() {
public BuildCommandResponse invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
try {
listener.getLogger().println("Docker Build : build with tag " + tagToUse + " at path " + f.getAbsolutePath());
DockerClient client = builder
.readTimeout(3600000).build();
File dockerFile;
// Be lenient and allow the user to just specify the path.
if( f.isFile() )
dockerFile = f;
else
dockerFile = new File(f, "Dockerfile");
return client.createBuildCommand()
.dockerFile(dockerFile)
.tag(tagToUse)
.execute();
} catch (DockerException e) {
throw Throwables.propagate(e);
}
}
});
listener.getLogger().println("Docker Build Response : " + response);
Optional<String> id = response.imageId();
if( !id.isPresent() )
return false;
build.addAction( new DockerBuildImageAction(url, id.get(), tagToUse, cleanupWithJenkinsJobDelete, pushOnSuccess) );
build.save();