@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : getActions(EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
@Override public void buildEnvVars(Map<String,String> env) { EnvVars.resolve(varmap); env.putAll(varmap); }
private static void addArgs(ArgumentListBuilder args, EnvVars env, SonarInstallation sonarInstallation) { Map<String, String> props = getSonarProps(sonarInstallation); args.add("end"); // expand macros using itself EnvVars.resolve(props); for (Map.Entry<String, String> e : props.entrySet()) { if (!StringUtils.isEmpty(e.getValue())) { // expand macros using environment variables and hide token boolean hide = e.getKey().contains("sonar.login"); args.addKeyValuePair("/d:", e.getKey(), env.expand(e.getValue()), hide); } } args.addTokenized(sonarInstallation.getAdditionalProperties()); }
env2.putAll(((AbstractBuild<?,?>) build).getBuildVariables()); EnvVars.resolve(env2); for (int i = 0; i < outLocations.length; i++) { outLocations[i] = locations[i].getExpandedLocation(env2);
EnvVars.resolve(map);
/** * Create the container environment. * We can't just pass result of {@link AbstractBuild#getEnvironment(TaskListener)}, as this one do include slave host * environment, that may not make any sense inside container (consider <code>PATH</code> for sample). */ private EnvVars buildContainerEnvironment(AbstractBuild build, BuildListener listener) throws IOException, InterruptedException { EnvVars env = build.getEnvironment(listener); for (String key : Computer.currentComputer().getEnvironment().keySet()) { env.remove(key); } LOGGER.log(Level.FINE, "reduced environment: {0}", env); EnvVars.resolve(env); return env; }
private void addArgsTo(ArgumentListBuilder args, SonarInstallation sonarInst, EnvVars env, Map<String, String> props) { args.add("begin"); args.add("/k:" + env.expand(projectKey) + ""); args.add("/n:" + env.expand(projectName) + ""); args.add("/v:" + env.expand(projectVersion) + ""); // expand macros using itself EnvVars.resolve(props); for (Map.Entry<String, String> e : props.entrySet()) { if (!StringUtils.isEmpty(e.getValue())) { // expand macros using environment variables and hide token boolean hide = e.getKey().contains("sonar.login"); args.addKeyValuePair("/d:", e.getKey(), env.expand(e.getValue()), hide); } } args.add(sonarInst.getAdditionalAnalysisPropertiesWindows()); args.addTokenized(sonarInst.getAdditionalProperties()); args.addTokenized(env.expand(additionalArguments)); }
@Override public EnvVars getEnvironment(TaskListener listener) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(listener); Jenkins instance = Jenkins.getInstance(); if (instance != null) { for (NodeProperty nodeProperty : instance.getGlobalNodeProperties()) { nodeProperty.buildEnvVars(env, listener); } } // TODO EnvironmentContributingAction does not support Job yet: ParametersAction a = getAction(ParametersAction.class); if (a != null) { for (ParameterValue v : a) { v.buildEnvironment(this, env); } } EnvVars.resolve(env); return env; }
private static EnvVars getDefaultParameterValuesAsEnvVars(AbstractProject owner) { EnvVars envVars = null; ParametersDefinitionProperty parametersDefinitionProperty = (ParametersDefinitionProperty)owner.getProperty(ParametersDefinitionProperty.class); if (parametersDefinitionProperty!=null){ envVars = new EnvVars(); for (ParameterDefinition parameterDefinition: parametersDefinitionProperty.getParameterDefinitions()){ ParameterValue defaultParameterValue = parameterDefinition.getDefaultParameterValue(); if (defaultParameterValue!=null){ if (defaultParameterValue instanceof StringParameterValue){ envVars.put(parameterDefinition.getName(), ((StringParameterValue)defaultParameterValue).value); } } } EnvVars.resolve(envVars); } return envVars; } /**
@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : getActions(EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
EnvVars.resolve(env); } else { env = new EnvVars(System.getenv());
EnvVars.resolve(env); } else { env = new EnvVars(System.getenv());
EnvVars.resolve(env);
@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); // servlet container may have set CLASSPATH in its launch script, // so don't let that inherit to the new child process. // see http://www.nabble.com/Run-Job-with-JDK-1.4.2-tf4468601.html env.put("CLASSPATH",""); JDK jdk = project.getJDK(); if (jdk != null) { Computer computer = Computer.currentComputer(); if (computer != null) { // just in case were not in a build jdk = jdk.forNode(computer.getNode(), log); } jdk.buildEnvVars(env); } project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : Util.filter(getActions(),EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); // servlet container may have set CLASSPATH in its launch script, // so don't let that inherit to the new child process. // see http://www.nabble.com/Run-Job-with-JDK-1.4.2-tf4468601.html env.put("CLASSPATH",""); JDK jdk = project.getJDK(); if (jdk != null) { Computer computer = Computer.currentComputer(); if (computer != null) { // just in case were not in a build jdk = jdk.forNode(computer.getNode(), log); } jdk.buildEnvVars(env); } project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : Util.filter(getActions(),EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
@Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars env = super.getEnvironment(log); FilePath ws = getWorkspace(); if (ws!=null) // if this is done very early on in the build, workspace may not be decided yet. see HUDSON-3997 env.put("WORKSPACE", ws.getRemote()); // servlet container may have set CLASSPATH in its launch script, // so don't let that inherit to the new child process. // see http://www.nabble.com/Run-Job-with-JDK-1.4.2-tf4468601.html env.put("CLASSPATH",""); JDK jdk = project.getJDK(); if (jdk != null) { Computer computer = Computer.currentComputer(); if (computer != null) { // just in case were not in a build jdk = jdk.forNode(computer.getNode(), log); } jdk.buildEnvVars(env); } project.getScm().buildEnvVars(this,env); if (buildEnvironments!=null) for (Environment e : buildEnvironments) e.buildEnvVars(env); for (EnvironmentContributingAction a : Util.filter(getActions(),EnvironmentContributingAction.class)) a.buildEnvVars(this,env); EnvVars.resolve(env); return env; }
EnvVars.resolve(env);