@Override public final void preCheckout(AbstractBuild build, final Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (runPreCheckout()) { final Context c = new Context(); setUp(c, build, build.getWorkspace(), launcher, listener, build.getEnvironment(listener)); build.getEnvironments().add(new EnvironmentWrapper(c, launcher)); } }
/** * Convenient version of {@link #translate(Node, EnvVars, TaskListener)} that just takes a build object in progress. * @since 1.460 */ public ToolInstallation translate(AbstractBuild<?,?> buildInProgress, TaskListener listener) throws IOException, InterruptedException { assert buildInProgress.isBuilding(); return translate(buildInProgress.getBuiltOn(),buildInProgress.getEnvironment(listener),listener); }
@Override public final Environment setUp(AbstractBuild build, final Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (runPreCheckout()) { return new Environment() {}; } else { final Context c = new Context(); setUp(c, build, build.getWorkspace(), launcher, listener, build.getEnvironment(listener)); return new EnvironmentWrapper(c, launcher); } }
@Override public final void preCheckout(AbstractBuild build, final Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (runPreCheckout()) { final Context c = new Context(); setUp(c, build, build.getWorkspace(), launcher, listener, build.getEnvironment(listener)); build.getEnvironments().add(new EnvironmentWrapper(c, launcher)); } }
@Override public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) { if (StringUtils.isEmpty(path)) { return null; } try { EnvVars env = build.getEnvironment(listener); String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver()); targetPath = env.expand(targetPath); if (IOUtils.isAbsolute(targetPath)) { return new FilePath(new File(targetPath)); } else { FilePath mrSettings = build.getModuleRoot().child(targetPath); FilePath wsSettings = build.getWorkspace().child(targetPath); try { if (!wsSettings.exists() && mrSettings.exists()) { wsSettings = mrSettings; } } catch (Exception e) { throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote()); } return wsSettings; } } catch (Exception e) { throw new IllegalStateException("failed to prepare global settings.xml"); } }
@Override public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) { if (StringUtils.isEmpty(path)) { return null; } try { EnvVars env = build.getEnvironment(listener); String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver()); targetPath = env.expand(targetPath); if (IOUtils.isAbsolute(targetPath)) { return new FilePath(new File(targetPath)); } else { FilePath mrSettings = build.getModuleRoot().child(targetPath); FilePath wsSettings = build.getWorkspace().child(targetPath); try { if (!wsSettings.exists() && mrSettings.exists()) { wsSettings = mrSettings; } } catch (Exception e) { throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote()); } return wsSettings; } } catch (Exception e) { throw new IllegalStateException("failed to prepare settings.xml"); } }
EnvVars envVars = build.getEnvironment(listener);
VariableResolver<String> vr = build.getBuildVariableResolver(); EnvVars env = build.getEnvironment(listener);
@Override public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { ... final EnvVars env = build.getEnvironment(listener); String expandedDbUrl = env.expand(dbUrl); ... }
public static Map<String, String> getEnvFor(AbstractBuild<?, ?> build, TaskListener log) { Map<String, String> evMap = new HashMap<String, String>(); evMap.putAll(build.getBuildVariables()); try { evMap.putAll(build.getEnvironment(log)); } catch (IOException e) { //Do nothing } catch (InterruptedException e) { //Do nothing } return evMap; }
private TreeMap<String, String> getEnvironmentVariables(final AbstractBuild<?, ?> build, final TaskListener listener) { try { final TreeMap<String, String> env = build.getEnvironment(listener); env.putAll(build.getBuildVariables()); return env; } catch (Exception e) { throw new RuntimeException(Messages.exception_failedToGetEnvVars(), e); } }
/** * Retrieve the build environment from the upstream build */ public EnvVars getEnvironment(AbstractBuild<?,?> build, TaskListener listener) throws IOException, InterruptedException { CapturedEnvironmentAction capture = build.getAction(CapturedEnvironmentAction.class); if (capture != null) { return capture.getCapturedEnvironment(); } else { return build.getEnvironment(listener); } }
private DebianPackageRepo getRepo(AbstractBuild<?, ?> build, Runner runner) throws IOException, InterruptedException { String expandedRepo = build.getEnvironment(runner.getListener()).expand(repoId); for(DebianPackageRepo repo: getDescriptor().getRepositories()) { if (repo.getName().equals(expandedRepo)) { return repo; } } throw new IllegalArgumentException(MessageFormat.format("Repo {0} is not found in global configuration", expandedRepo)); }
/** * Convenient version of {@link #translate(Node, EnvVars, TaskListener)} that just takes a build object in progress. * @since 1.460 */ public ToolInstallation translate(AbstractBuild<?,?> buildInProgress, TaskListener listener) throws IOException, InterruptedException { assert buildInProgress.isBuilding(); return translate(buildInProgress.getBuiltOn(),buildInProgress.getEnvironment(listener),listener); }
public Docker(DockerServerEndpoint dockerHost, String dockerInstallation, String credentialsId, AbstractBuild build, Launcher launcher, TaskListener listener, boolean verbose, boolean privileged) throws IOException, InterruptedException { this.dockerHost = dockerHost; this.dockerExecutable = DockerTool.getExecutable(dockerInstallation, Computer.currentComputer().getNode(), listener, build.getEnvironment(listener)); this.registryEndpoint = new DockerRegistryEndpoint(null, credentialsId); this.launcher = launcher; this.listener = listener; this.build = build; this.verbose = verbose | debug; this.privileged = privileged; }
@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (debug) { listener.getLogger().println("Running mailer"); } // substitute build parameters EnvVars env = build.getEnvironment(listener); String recip = env.expand(recipients); return new MailSender(recip, dontNotifyEveryUnstableBuild, sendToIndividuals, descriptor().getCharset()).execute(build, listener); }
@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (debug) { listener.getLogger().println("Running mailer"); } // substitute build parameters EnvVars env = build.getEnvironment(listener); String recip = env.expand(recipients); return new MailSender(recip, dontNotifyEveryUnstableBuild, sendToIndividuals, descriptor().getCharset()).execute(build, listener); }
@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (debug) { listener.getLogger().println("Running mailer"); } // substitute build parameters EnvVars env = build.getEnvironment(listener); String recip = env.expand(recipients); return new MailSender(recip, dontNotifyEveryUnstableBuild, sendToIndividuals, descriptor().getCharset()).execute(build, listener); }
@Override public final Environment setUp(AbstractBuild build, final Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (runPreCheckout()) { return new Environment() {}; } else { final Context c = new Context(); setUp(c, build, build.getWorkspace(), launcher, listener, build.getEnvironment(listener)); return new EnvironmentWrapper(c, launcher); } }
public GitCommitHelper(AbstractBuild<?, ?> build, GitSCM scm, Runner runner, String commitMessage, Collection<String> modules) throws IOException, InterruptedException { this.commitMessage = commitMessage; this.modules = modules; this.environment = build.getEnvironment(runner.getListener()); this.listener = runner.getListener(); this.gitExe = scm.getGitExe(build.getBuiltOn(), listener); this.gitPrefix = scm.getRelativeTargetDir(); DescriptorImpl descriptor = (DescriptorImpl) Jenkins.getInstance().getDescriptor(DebianPackageBuilder.class); this.accountName = descriptor.getAccountName(); this.accountEmail = descriptor.getAccountEmail(); }