/** * @deprecated Call {@link #newKeyMaterialFactory(Item, VirtualChannel, Launcher, TaskListener)} */ @Deprecated public KeyMaterialFactory newKeyMaterialFactory(Item context, @Nonnull VirtualChannel target) throws IOException, InterruptedException { return newKeyMaterialFactory(context, target, null, TaskListener.NULL); }
/** * @deprecated Call {@link #newKeyMaterialFactory(Item, FilePath, Launcher, EnvVars, TaskListener, String)} */ @Deprecated public KeyMaterialFactory newKeyMaterialFactory(Item context, @Nonnull VirtualChannel target) throws IOException, InterruptedException { return newKeyMaterialFactory(context, target, null, TaskListener.NULL); }
/** * @deprecated Call {@link #newKeyMaterialFactory(Item, FilePath, Launcher, EnvVars, TaskListener, String)} */ @Deprecated public KeyMaterialFactory newKeyMaterialFactory(@CheckForNull Item context, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener, @Nonnull String dockerExecutable) throws IOException, InterruptedException { return newKeyMaterialFactory(context, workspace, launcher, new EnvVars(), listener, dockerExecutable); }
@Override protected KeyMaterialFactory newKeyMaterialFactory() throws IOException, InterruptedException { return step.registry.newKeyMaterialFactory(job, workspace, launcher, envVars, listener, DockerTool.getExecutable(step.toolName, node, listener, envVars)); }
/** * @deprecated Call {@link #newKeyMaterialFactory(Item, FilePath, Launcher, EnvVars, TaskListener, String)} */ @Deprecated public KeyMaterialFactory newKeyMaterialFactory(@Nonnull AbstractBuild build) throws IOException, InterruptedException { final FilePath workspace = build.getWorkspace(); if (workspace == null) { throw new IllegalStateException("Requires workspace."); } return newKeyMaterialFactory(build.getParent(), workspace.getChannel()); }
/** * @deprecated Call {@link #newKeyMaterialFactory(Item, VirtualChannel, Launcher, TaskListener)} */ @Deprecated public KeyMaterialFactory newKeyMaterialFactory(@Nonnull AbstractBuild build) throws IOException, InterruptedException { final FilePath workspace = build.getWorkspace(); if (workspace == null) { throw new IllegalStateException("Requires workspace."); } return newKeyMaterialFactory(build.getParent(), workspace.getChannel()); }
public void setupCredentials(AbstractBuild build) throws IOException, InterruptedException { this.dockerEnv = dockerHost.newKeyMaterialFactory(build) .plus( registryEndpoint.newKeyMaterialFactory(build)) .materialize(); }
@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; }
getRegistry().newKeyMaterialFactory(build) .plus(