@Override public void buildEnvVars(Map<String,String> env) { if (env instanceof EnvVars) { ((EnvVars) env).overrideAll(c.env); } else { // ? env.putAll(c.env); } } @Override public boolean tearDown(AbstractBuild build, BuildListener listener) throws IOException, InterruptedException {
@Override public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException { GitLabWebHookCause cause = null; if (r instanceof MatrixRun) { MatrixBuild parent = ((MatrixRun)r).getParentBuild(); if (parent != null) { cause = (GitLabWebHookCause) parent.getCause(GitLabWebHookCause.class); } } else { cause = (GitLabWebHookCause) r.getCause(GitLabWebHookCause.class); } if (cause != null) { envs.overrideAll(cause.getData().getBuildVariables()); } } }
@Override public void buildEnvironmentFor(Run r, EnvVars env, TaskListener listener) throws IOException, InterruptedException { Computer c = Computer.currentComputer(); if (c!=null){ EnvVars compEnv = c.getEnvironment().overrideAll(env); env.putAll(compEnv); } env.put("BUILD_DISPLAY_NAME",r.getDisplayName()); Jenkins j = Jenkins.getInstance(); String rootUrl = j.getRootUrl(); if(rootUrl!=null) { env.put("BUILD_URL", rootUrl+r.getUrl()); } }
@Override public void expand(EnvVars env) throws IOException, InterruptedException { env.overrideAll(envMap); } }
@Override public void expand(EnvVars env) throws IOException, InterruptedException { env.overrideAll(overrides); } }
@Override public void expand(EnvVars env) throws IOException, InterruptedException { env.overrideAll(overrides); } }
@Override public void expand(EnvVars env) throws IOException, InterruptedException { env.overrideAll(envMap); } }
@Override public void buildEnvVars(Map<String,String> env) { if (env instanceof EnvVars) { ((EnvVars) env).overrideAll(c.env); } else { // ? env.putAll(c.env); } } @Override public boolean tearDown(AbstractBuild build, BuildListener listener) throws IOException, InterruptedException {
@Override public void expand(@Nonnull EnvVars envVars) { envVars.overrideAll(awsEnv); } };
@Override public void expand(EnvVars env) throws IOException, InterruptedException { LOGGER.log(Level.FINEST, "ExpanderImpl.expand - env before expand: {0}", new Object[]{env}); // JENKINS-40484 env.overrideAll(overrides); LOGGER.log(Level.FINEST, "ExpanderImpl.expand - env after expand: {0}", new Object[]{env}); // JENKINS-40484 } }
private void addEnvVars(Action action, EnvVars envVars) { try { Class<? extends Action> actionClass = action.getClass(); Method method = actionClass.getMethod("getOverriddenEnvironment"); Map<String, String> map = (Map<String, String>) method.invoke(action); envVars.overrideAll(map); } catch (Throwable ex) { LOGGER.warning("Failed to add envVars from action: " + action.getClass()); } }
protected String resolveFilePaths(Run<?, ?> build, TaskListener listener, String input, Map<String, String> env) throws InterruptedException, IOException { try { final EnvVars environment = build.getEnvironment(listener); environment.overrideAll(env); return environment.expand(input); } catch (IOException e) { throw new IOException("Failed to resolve parameters in string \""+ input+"\"", e); } catch (RuntimeException e) { throw new RuntimeException("Failed to resolve parameters in string \""+ input+"\"", e); } }
/** * Get environment vars of the run, with all values overridden by build vars */ public static EnvVars getEnvAndBuildVars(Run<?, ?> run, TaskListener listener) throws IOException, InterruptedException { EnvVars env = run.getEnvironment(listener); if (run instanceof AbstractBuild) { env.overrideAll(((AbstractBuild<?, ?>) run).getBuildVariables()); } return env; }
@Override public EnvVars getEnvironment() throws IOException, InterruptedException { EnvVars env2 = super.getEnvironment(); env2.overrideAll(env); return env2; } }
private EnvVars getEnvVars() throws IOException, InterruptedException { if (envVars == null) { envVars = new EnvVars(build.getEnvironment(listener)).overrideAll(dockerEnv.env()); } return envVars; }
private void withEndpointUrl(@Nonnull EnvVars localEnv) throws IOException, InterruptedException { if (!StringUtils.isNullOrEmpty(this.step.getEndpointUrl())) { this.getContext().get(TaskListener.class).getLogger().format("Setting AWS endpointUrl %s %n ", this.step.getEndpointUrl()); localEnv.override(AWSClientFactory.AWS_ENDPOINT_URL, this.step.getEndpointUrl()); this.envVars.overrideAll(localEnv); } }
public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars env) { for (NodeProperty nodeProperty: Hudson.getInstance().getGlobalNodeProperties()) { if (nodeProperty instanceof EnvironmentVariablesNodeProperty) { env.overrideAll(((EnvironmentVariablesNodeProperty)nodeProperty).getEnvVars()); } } for (NodeProperty nodeProperty: Computer.currentComputer().getNode().getNodeProperties()) { if (nodeProperty instanceof EnvironmentVariablesNodeProperty) { env.overrideAll(((EnvironmentVariablesNodeProperty)nodeProperty).getEnvVars()); } } } }
private void withRegion(@Nonnull EnvVars localEnv) throws IOException, InterruptedException { if (!StringUtils.isNullOrEmpty(this.step.getRegion())) { this.getContext().get(TaskListener.class).getLogger().format("Setting AWS region %s %n ", this.step.getRegion()); localEnv.override(AWSClientFactory.AWS_DEFAULT_REGION, this.step.getRegion()); localEnv.override(AWSClientFactory.AWS_REGION, this.step.getRegion()); this.envVars.overrideAll(localEnv); } }
private void withProfile(@Nonnull EnvVars localEnv) throws IOException, InterruptedException { if (!StringUtils.isNullOrEmpty(this.step.getProfile())) { this.getContext().get(TaskListener.class).getLogger().format("Setting AWS profile %s %n ", this.step.getProfile()); localEnv.override(AWSClientFactory.AWS_DEFAULT_PROFILE, this.step.getProfile()); localEnv.override(AWSClientFactory.AWS_PROFILE, this.step.getProfile()); this.envVars.overrideAll(localEnv); } }
@Override public void buildEnvironmentFor(Run r, EnvVars env, TaskListener listener) throws IOException, InterruptedException { Computer c = Computer.currentComputer(); if (c!=null){ EnvVars compEnv = c.getEnvironment().overrideAll(env); env.putAll(compEnv); } env.put("BUILD_DISPLAY_NAME",r.getDisplayName()); Jenkins j = Jenkins.getInstance(); String rootUrl = j.getRootUrl(); if(rootUrl!=null) { env.put("BUILD_URL", rootUrl+r.getUrl()); } }