private String getNodeDefinedMavenHome(AbstractBuild<?, ?> build) { Node currentNode = build.getBuiltOn(); DescribableList<NodeProperty<?>, NodePropertyDescriptor> properties = currentNode.getNodeProperties(); ToolLocationNodeProperty toolLocation = properties.get(ToolLocationNodeProperty.class); if (toolLocation != null) { List<ToolLocationNodeProperty.ToolLocation> locations = toolLocation.getLocations(); if (locations != null) { for (ToolLocationNodeProperty.ToolLocation location : locations) { if (location.getType().isSubTypeOf(Maven.MavenInstallation.class)) { String installationHome = location.getHome(); if (StringUtils.isNotBlank(installationHome)) { return installationHome; } } } } } return null; }
/** * Creates an environment variable override to be used for launching processes on this node. * * @see ProcStarter#envs(Map) * @since 1.489 */ public EnvVars buildEnvironment(TaskListener listener) throws IOException, InterruptedException { EnvVars env = new EnvVars(); Node node = getNode(); if (node == null) return env; // bail out for (NodeProperty nodeProperty : Jenkins.getInstance().getGlobalNodeProperties()) { nodeProperty.buildEnvVars(env, listener); } for (NodeProperty nodeProperty : node.getNodeProperties()) { nodeProperty.buildEnvVars(env, listener); } // TODO: hmm, they don't really belong String rootUrl = Hudson.getInstance().getRootUrl(); if (rootUrl != null) { env.put("HUDSON_URL", rootUrl); // Legacy. env.put("JENKINS_URL", rootUrl); } return env; }