} else { mi = mi.forNode(Computer.currentComputer().getNode(), listener); mi = mi.forEnvironment(env); String exec = mi.getExecutable(launcher); if(exec==null) {
private String obtainMvnExecutableFromMavenInstallation(String mavenInstallationName) throws IOException, InterruptedException { MavenInstallation mavenInstallation = null; for (MavenInstallation i : getMavenInstallations()) { if (mavenInstallationName.equals(i.getName())) { mavenInstallation = i; LOGGER.log(Level.FINE, "Found maven installation {0} with installation home {1}", new Object[]{mavenInstallation.getName(), mavenInstallation.getHome()}); break; } } if (mavenInstallation == null) { throw new AbortException("Could not find specified Maven installation '" + mavenInstallationName + "'."); } Node node = getComputer().getNode(); if (node == null) { throw new AbortException("Could not obtain the Node for the computer: " + getComputer().getName()); } mavenInstallation = mavenInstallation.forNode(node, listener).forEnvironment(env); mavenInstallation.buildEnvVars(envOverride); console.println("[withMaven] using Maven installation '" + mavenInstallation.getName() + "'"); String mvnExecPath = mavenInstallation.getExecutable(launcher); return mvnExecPath; }
private FilePath getMavenHome(TaskListener listener, EnvVars env, Launcher launcher) throws IOException, InterruptedException { if (StringUtils.isNotEmpty(mavenName)) { Maven.MavenInstallation mi = getMaven(); if (mi == null) { listener.error("Couldn't find Maven executable."); throw new Run.RunnerAbortedException(); } else { Node node = ActionableHelper.getNode(launcher); mi = mi.forNode(node, listener); mi = mi.forEnvironment(env); } return new FilePath(launcher.getChannel(), mi.getHome()); } if (env.get(MAVEN_HOME) != null) { return new FilePath(launcher.getChannel(), env.get(MAVEN_HOME)); } throw new RuntimeException("Couldn't find maven installation"); }
throw new AbortException(Messages.MavenModuleSetBuild_NoMavenConfigured()); mvn = mvn.forEnvironment(envVars).forNode(Computer.currentComputer().getNode(), listener);
"Either your server has no Maven installations defined, or the requested Maven version does not exist."); mvn = mvn.forEnvironment(envVars).forNode(Computer.currentComputer().getNode(), listener);
mvn = mvn.forEnvironment(envVars).forNode(Computer.currentComputer().getNode(), listener);
mvn = mvn.forEnvironment(envVars).forNode(Computer.currentComputer().getNode(), listener);
} else { mi = mi.forNode(Computer.currentComputer().getNode(), listener); mi = mi.forEnvironment(env); String exec = mi.getExecutable(launcher); if(exec==null) {
} else { mi = mi.forNode(Computer.currentComputer().getNode(), listener); mi = mi.forEnvironment(env); String exec = mi.getExecutable(launcher); if(exec==null) {
} else { mi = mi.forNode(Computer.currentComputer().getNode(), listener); mi = mi.forEnvironment(env); String exec = mi.getExecutable(launcher); if(exec==null) {
} else { mi = mi.forNode(Computer.currentComputer().getNode(), listener); mi = mi.forEnvironment(env); String exec = mi.getExecutable(launcher); if(exec==null) {
} else { mi = mi.forNode(Computer.currentComputer().getNode(), listener); mi = mi.forEnvironment(env); String exec = mi.getExecutable(launcher); if (exec == null) {
mvn = mvn.forEnvironment(envs);
/** * Get the {@link hudson.model.EnvironmentSpecific} and {@link hudson.slaves.NodeSpecific} Maven installation. First * get the descriptor from the global Jenkins. Then populate it accordingly from the specific environment node that * the process is currently running in e.g. the MAVEN_HOME variable may be defined only in the remote node and * Jenkins is not persisting it as part of its installations. * * @param build The Maven project build that the maven installation is taken from. * @param vars The build's environment variables. * @param listener The build's event listener * @throws hudson.AbortException If the {@link hudson.tasks.Maven.MavenInstallation} that is taken from the project * is {@code null} then this exception is thrown. */ private static Maven.MavenInstallation getMavenInstallation(MavenModuleSetBuild build, EnvVars vars, TaskListener listener) throws IOException, InterruptedException { MavenModuleSet project = build.getProject(); Maven.MavenInstallation mavenInstallation = project.getMaven(); if (mavenInstallation == null) { throw new AbortException("A Maven installation needs to be available for this project to be built.\n" + "Either your server has no Maven installations defined, or the requested Maven version does not exist."); } return mavenInstallation.forEnvironment(vars).forNode(build.getBuiltOn().toComputer().getNode(), listener); }
/** * Exposes {@code MAVEN_OPTS} to forked processes. * * <p> * See {@link MavenModuleSetBuild#getEnvironment(TaskListener)} for discussion. */ @Override public EnvVars getEnvironment(TaskListener log) throws IOException, InterruptedException { EnvVars envs = super.getEnvironment(log); // We need to add M2_HOME and the mvn binary to the PATH so if Maven // needs to run Maven it will pick the correct one. // This can happen if maven calls ANT which itself calls Maven // or if Maven calls itself e.g. maven-release-plugin MavenInstallation mvn = project.getParent().getMaven(); if (mvn == null) throw new hudson.AbortException(Messages.MavenModuleSetBuild_NoMavenConfigured()); mvn = mvn.forEnvironment(envs).forNode(Computer.currentComputer().getNode(), log); mvn.buildEnvVars(envs); return envs; }
public MavenInstallation getMavenInstallation(TaskListener log) throws IOException, InterruptedException { MavenInstallation mi = mms.getMaven(); if (mi != null) mi = mi.forNode(getCurrentNode(), log).forEnvironment(envVars); return mi; }
public MavenInstallation getMavenInstallation(TaskListener log) throws IOException, InterruptedException { MavenInstallation mi = mms.getMaven(); if (mi != null) mi = mi.forNode(getCurrentNode(), log).forEnvironment(envVars); return mi; }