/** * Builds the command line argument list to launch the maven process. */ protected ArgumentListBuilder buildMavenAgentCmdLine(BuildListener listener, String tcpSocket) throws IOException, InterruptedException { return buildMavenAgentCmdLine(listener, tcpSocket, getJava(listener)); }
@CheckForNull public JDK getJava(TaskListener log) throws IOException, InterruptedException { JDK jdk = mms.getJDK(); if (jdk != null) jdk = jdk.forNode(getCurrentNode(), log).forEnvironment(envVars); return jdk; }
public String getMavenOpts() { if( this.mavenOpts != null ) return addRunHeadLessOption(this.mavenOpts); String mavenOpts = mms.getMavenOpts(); if ((mavenOpts==null) || (mavenOpts.trim().length()==0)) { Node n = getCurrentNode(); if (n!=null) { try { String localMavenOpts = n.toComputer().getEnvironment().get("MAVEN_OPTS"); if ((localMavenOpts!=null) && (localMavenOpts.trim().length()>0)) { mavenOpts = localMavenOpts; } } catch (IOException e) { } catch (InterruptedException e) { // Don't do anything - this just means the slave isn't running, so we // don't want to use its MAVEN_OPTS anyway. } } } mavenOpts = addRunHeadLessOption(mavenOpts); return envVars.expand(mavenOpts); }
private ArgumentListBuilder buildMavenAgentCmdLine(BuildListener listener, String tcpSocket, JDK jdk) throws IOException, InterruptedException { MavenInstallation mvn = getMavenInstallation(listener); if(mvn==null) { listener.error("Maven version is not configured for this project. Can't determine which Maven to run"); boolean isMaster = getCurrentNode()== Jenkins.getInstance(); FilePath slaveRoot=null; if(!isMaster) slaveRoot = getCurrentNode().getRootPath(); args.add("-agentlib:yjpagent=tracing"); args.addTokenized(getMavenOpts()); args.add(getMavenAgentClassPath(mvn, slaveRoot, listener)); args.add(getMainClassName()); String remotingJar = getLauncher().getChannel().call(new GetRemotingJar()); if(remotingJar==null) {// this shouldn't be possible, but there are still reports indicating this, so adding a probe here. listener.error("Failed to determine the location of slave.jar"); args.add(getMavenInterceptorClassPath(mvn, slaveRoot, listener)); String mavenInterceptorCommonClasspath = getMavenInterceptorCommonClassPath(mvn, slaveRoot, listener); String interceptorOverride = getMavenInterceptorOverride(mvn, slaveRoot, listener); if (interceptorOverride!=null) { args.add(interceptorOverride);
JDK jdk = getJava(listener); JDK originalJdk = null; JDK: while (true) { listener.getLogger().println("Established TCP socket on "+ socket); final ArgumentListBuilder cmdLine = buildMavenAgentCmdLine(listener, socket, jdk); String[] cmds = cmdLine.toCommandArray(); final Proc proc = launcher.launch().cmds(cmds).envs(envVars).stdout(mca).pwd(workDir).start(); applyPlexusModuleContributor(ch,build);
final ArgumentListBuilder cmdLine = buildMavenAgentCmdLine( listener,acceptor.getPort()); String[] cmds = cmdLine.toCommandArray(); final Proc proc = launcher.launch().cmds(cmds).envs(envVars).stdout(mca).pwd(workDir).start();
/** * Copies a Maven-related JAR to the slave on demand. * Can also be used when run on master. * @param root the FS root of the slave (null means running on master) * @param representative a representative class present in the JAR * @param seedName the basename of the JAR * @param listener a listener for any problems * @return the (local or remote) absolute path of the JAR * @throws IOException in case copying fails * @throws InterruptedException in case copying is interrupted * @since 1.530 */ protected final String classPathEntry(FilePath root, Class<?> representative, String seedName, TaskListener listener) throws IOException, InterruptedException { if (root == null) { // master return Which.jarFile(representative).getAbsolutePath(); } else { return copyJar(listener.getLogger(), root, representative, seedName).getRemote(); } } /**
public String getMavenOpts() { String mavenOpts = mms.getMavenOpts(); if ((mavenOpts==null) || (mavenOpts.trim().length()==0)) { Node n = getCurrentNode(); if (n!=null) { try { String localMavenOpts = n.toComputer().getEnvironment().get("MAVEN_OPTS"); if ((localMavenOpts!=null) && (localMavenOpts.trim().length()>0)) { mavenOpts = localMavenOpts; } } catch (IOException e) { } catch (InterruptedException e) { // Don't do anything - this just means the slave isn't running, so we // don't want to use its MAVEN_OPTS anyway. } } } return envVars.expand(mavenOpts); }
public JDK getJava(TaskListener log) throws IOException, InterruptedException { JDK jdk = mms.getJDK(); if (jdk != null) jdk = jdk.forNode(getCurrentNode(), log).forEnvironment(envVars); return jdk; }
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; }