private void cutCycle(List<String> cycle) { // if an existing variable is contained in that cycle, // cut the cycle with that variable: // existing: // PATH=/usr/bin // overriding: // PATH1=/usr/local/bin:${PATH} // PATH=/opt/something/bin:${PATH1} // then consider reference PATH1 -> PATH can be ignored. for (String referee: cycle) { if (target.containsKey(referee)) { cutCycleAt(referee, cycle); return; } } // if not, cut the reference to the first one. cutCycleAt(cycle.get(0), cycle); }
private void cutCycle(List<String> cycle) { // if an existing variable is contained in that cycle, // cut the cycle with that variable: // existing: // PATH=/usr/bin // overriding: // PATH1=/usr/local/bin:${PATH} // PATH=/opt/something/bin:${PATH1} // then consider reference PATH1 -> PATH can be ignored. for (String referee: cycle) { if (target.containsKey(referee)) { cutCycleAt(referee, cycle); return; } } // if not, cut the reference to the first one. cutCycleAt(cycle.get(0), cycle); }
private List<String> lookForJavaHome(Node node) { List<String> ret = new ArrayList<>(); if(node != null && node.getNodeProperties() != null){ for (NodeProperty property : node.getNodeProperties()){ if(property instanceof EnvironmentVariablesNodeProperty){ EnvVars env = ((EnvironmentVariablesNodeProperty) property).getEnvVars(); if (env != null && env.containsKey(JAVA_HOME)) { ret.add(env.get(JAVA_HOME) + BIN_JAVA); } } } } return ret; }
@Override public boolean permitsMethod(@Nonnull Method method, @Nonnull Object receiver, @Nonnull Object[] args) { //method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (SimpleTemplateScript2 BUILD_ID) if (method.getDeclaringClass() == GroovyObject.class && receiver instanceof EmailExtScript && "invokeMethod".equals(method.getName()) && args.length > 0) { EmailExtScript script = (EmailExtScript)receiver; String name = String.valueOf(args[0]); for (TokenMacro m : macros) { if (m.acceptsMacroName(name)) { return true; } } //Else check environment Run<?,?> build = (Run<?,?>)script.getBinding().getVariable("build"); TaskListener listener = (TaskListener)script.getBinding().getVariable("listener"); try { EnvVars vars = build.getEnvironment(listener); return vars.containsKey(name); } catch (IOException | InterruptedException e) { Logger.getLogger(getClass().getName()).log(Level.WARNING, "Failed to expand environment when evaluating " + name + " on " + build.getExternalizableId(), e); } } return false; } }
public boolean isValid(Job<?,?> job) { if (filters.isEmpty()) return false; // Unable to parse text after / // Consider the filter valid for this job if any build for this job has all the filter params outer: for (Run<?,?> run = job.getLastCompletedBuild(); run != null; run = run.getPreviousCompletedBuild()) try { EnvVars env = run.getEnvironment(TaskListener.NULL); for (StringParameterValue spv : filters) { if (!env.containsKey(spv.getName())) { continue outer; } } return true; } catch (InterruptedException ignore) { } catch (IOException ignore) { } return false; }
if (compEnv.containsKey(key)) { return compEnv.get(key); if (env.containsKey(key)) { return env.get(key);
public static String getNpmExe(TaskListener listener, EnvVars env, Launcher launcher, String nodeTool) throws IOException, InterruptedException { // npm from tool if (StringUtils.isNotEmpty(nodeTool)) { NodeJSInstallation nodeInstallation = getNpmInstallation(nodeTool); if (nodeInstallation == null) { listener.error("Couldn't find NodeJS tool '" + nodeTool + "'"); throw new Run.RunnerAbortedException(); } Node node = ActionableHelper.getNode(launcher); nodeInstallation = nodeInstallation.forNode(node, listener).forEnvironment(env); String nodeExe = nodeInstallation.getExecutable(launcher); return Paths.get(nodeExe).resolveSibling("npm").toString(); } // npm from environment if (env.containsKey("NODEJS_HOME")) { return Paths.get(env.get("NODEJS_HOME"), "bin", "npm").toString(); } // npm from path return ""; }
private ConanClient getConanClient() throws Exception { ConanClient conanClient = step.getClient(); FilePath conanHomeDirectory; if (StringUtils.isEmpty(conanClient.getUserPath())) { conanHomeDirectory = env.containsKey(Utils.CONAN_USER_HOME) ? new FilePath(new File(env.get(Utils.CONAN_USER_HOME))) : createConanTempHome(); } else { conanHomeDirectory = new FilePath(launcher.getChannel(), conanClient.getUserPath()); if (!conanHomeDirectory.exists()) { conanHomeDirectory.mkdirs(); } } conanClient.setUserPath(conanHomeDirectory.getRemote()); conanHomeDirectory.child(ConanClient.CONAN_LOG_FILE).touch(Calendar.getInstance().getTimeInMillis()); return conanClient; }
if (prop instanceof EnvironmentVariablesNodeProperty) { EnvVars env = ((EnvironmentVariablesNodeProperty)prop).getEnvVars(); if (env != null && env.containsKey("JAVA_HOME")) javas.add(env.get("JAVA_HOME") + "/bin/java");
if (java == null && envVars.containsKey("JAVA_HOME")) { java = getJavaBinFromjavaHome(workingDirectory, envVars.get("JAVA_HOME"));
if (!env.containsKey("GIT_ASKPASS")) { freshEnv.put("GIT_ASKPASS", "echo"); try { args.prepend(gitExe); if (CALL_SETSID && launcher.isUnix() && env.containsKey("GIT_SSH") && env.containsKey("DISPLAY")) {
private String getGradleExe() throws IOException, InterruptedException { if (StringUtils.isNotEmpty(gradleBuild.getTool())) { GradleInstallation gi = getGradleInstallation(); if (gi == null) { listener.error("Couldn't find Gradle executable."); throw new Run.RunnerAbortedException(); } else { Node node = ActionableHelper.getNode(launcher); gi = gi.forNode(node, listener); gi = gi.forEnvironment(extendedEnv); } extendedEnv.put("GRADLE_HOME", gi.getHome()); String gradleExe = gi.getExecutable(launcher); if (gradleExe != null) { return gradleExe; } } if (!extendedEnv.containsKey("GRADLE_HOME")) { throw new RuntimeException("Couldn't find gradle installation"); } return extendedEnv.get("GRADLE_HOME") + "/bin/gradle"; }
/** * Get the consolidated environment for the provided build. * * @param build * The build * @param listener * The build listener * @return The consolidated environment * @throws IOException * @throws InterruptedException */ public static EnvVars getEnvironment(AbstractBuild<?, ?> build, BuildListener listener) throws IOException, InterruptedException { // Get the base environment EnvVars environment = build.getEnvironment(listener); // Add build variables, for instance if user defined a text axis environment.overrideAll(build.getBuildVariables()); // Check if define some nasty variables for (String key : EnvVarsUtil.getPythonHomeKeys()) // Check if key is contained if (environment.containsKey(key)) { // Log the error listener.fatalError(Messages.BuilderUtil_PythonHomeKeyFound(key)); // Notify to do not continue the build return null; } // Return the consolidated environment return environment; }
TaskListener listener = (TaskListener)this.getBinding().getVariable("listener"); EnvVars vars = build.getEnvironment(listener); if(vars.containsKey(name)) { return vars.get(name, "");
if (!environment.containsKey(PythonAxis.KEY)) {
if (!env.containsKey("HUDSON_HOME")) { env.put("HUDSON_HOME", Hudson.getInstance().getRootDir().getPath()); if (!env.containsKey(EnvVars.HUDSON_USER_ENV_KEY)) { String value = EnvVars.getHudsonUserEnvValue(); if (null != value) {
if (!env.containsKey("HUDSON_HOME")) { env.put("HUDSON_HOME", Hudson.getInstance().getRootDir().getPath()); if (!env.containsKey(EnvVars.HUDSON_USER_ENV_KEY)) { String value = EnvVars.getHudsonUserEnvValue(); if (null != value) {
if (!env.containsKey("HUDSON_HOME")) { env.put("HUDSON_HOME", Hudson.getInstance().getRootDir().getPath()); if (!env.containsKey(EnvVars.HUDSON_USER_ENV_KEY)) { String value = EnvVars.getHudsonUserEnvValue(); if (null != value) {
if (!env.containsKey("HUDSON_HOME")) { env.put("HUDSON_HOME", Hudson.getInstance().getRootDir().getPath());
if (!env.containsKey("HUDSON_HOME")) { env.put("HUDSON_HOME", Hudson.getInstance().getRootDir().getPath());