@Override public void close() throws IOException { keys.close(); } }
@Override public void close() throws IOException { keys.close(); } }
@Override public void close() throws IOException { dockerEnv.close(); }
@Override protected void finished(StepContext context) throws Exception { try { material.close(); } catch (IOException x) { Logger.getLogger(AbstractEndpointStepExecution.class.getName()).log(Level.WARNING, null, x); } }
@Override public void close() throws IOException { Throwable first = null; for (int index = keyMaterials.length - 1; index >= 0; index--) { try { if (keyMaterials[index] != null) { keyMaterials[index].close(); } } catch (Throwable e) { first = first == null ? e : first; } } if (first != null) { if (first instanceof IOException) { throw (IOException) first; } else if (first instanceof RuntimeException) { throw (RuntimeException) first; } else { throw new IOException("Error closing credentials.", first); } } } }
@Override public void close() throws IOException { Throwable first = null; for (int index = keyMaterials.length - 1; index >= 0; index--) { try { if (keyMaterials[index] != null) { keyMaterials[index].close(); } } catch (Throwable e) { first = first == null ? e : first; } } if (first != null) { if (first instanceof IOException) { throw (IOException) first; } else if (first instanceof RuntimeException) { throw (RuntimeException) first; } else { throw new IOException("Error closing credentials.", first); } } } }
try { if (keyMaterials[index] != null) { keyMaterials[index].close();
try { if (keyMaterials[index] != null) { keyMaterials[index].close();
@Override public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { // TODO could maybe use Docker REST API, need first to check Java can talk with linux sockets // TODO maybe use DockerHost API int status = 0; KeyMaterial key = null; final EnvVars env = build.getEnvironment(listener); String expandedImage = env.expand(image); try { // get Docker registry credentials key = registry.newKeyMaterialFactory(build).materialize(); status = launcher.launch() .cmds("docker", "pull", registry.imageName(expandedImage)).envs(key.env()) .writeStdin().stdout(listener.getLogger()).stderr(listener.getLogger()).join(); if (status != 0) { throw new RuntimeException("Failed to pull docker image"); } } catch (IOException e) { throw new RuntimeException("Failed to pull docker image", e); } catch (InterruptedException e) { throw new RuntimeException("Failed to pull docker image", e); } finally { if (key != null) { key.close(); } } listener.getLogger().println("docker pull " + image); return true; }
dockerKeys.close();