Package hudson.util

Examples of hudson.util.ArgumentListBuilder


            MavenConsoleAnnotator mca = new MavenConsoleAnnotator(out,charset);

            if ( mavenRemoteUseInet ) {
                envVars.put(MAVEN_REMOTE_USEINET_ENV_VAR_NAME , "true" );
            }
            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();

            Connection con;
            try {
                con = acceptor.accept();
View Full Code Here


        boolean isMaster = getCurrentNode()== Jenkins.getInstance();
        FilePath slaveRoot=null;
        if(!isMaster)
            slaveRoot = getCurrentNode().getRootPath();

        ArgumentListBuilder args = new ArgumentListBuilder();
        JDK jdk = getJava(listener);
        if(jdk==null) {
            args.add("java");
        } else {
            args.add(jdk.getHome()+"/bin/java"); // use JDK.getExecutable() here ?
        }

        if(debugPort!=0)
            args.add("-Xrunjdwp:transport=dt_socket,server=y,address="+debugPort);
        if(yjp)
            args.add("-agentlib:yjpagent=tracing");

        args.addTokenized(getMavenOpts());
       
        args.add( "-cp" );
        args.add(getMavenAgentClassPath(mvn,isMaster,slaveRoot,listener));
        args.add(getMainClassName());

        // M2_HOME
        args.add(mvn.getHome());

        // remoting.jar
        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");
            throw new RunnerAbortedException();
        }
        args.add(remotingJar);

        // interceptor.jar
        args.add(getMavenInterceptorClassPath(mvn,isMaster,slaveRoot));

        // TCP/IP port to establish the remoting infrastructure
        args.add(tcpPort);
       
        String interceptorOverride = getMavenInterceptorOverride(mvn,isMaster,slaveRoot);
        if (interceptorOverride!=null) {
            args.add(interceptorOverride);
        }

        return args;
    }
View Full Code Here

                            process =
                                MavenBuild.mavenProcessCache.get( launcher.getChannel(), slistener,
                                                                  new MavenProcessFactory( project, launcher, envVars,getMavenOpts(listener, envVars),
                                                                                           pom.getParent() ) );
                        }
                        ArgumentListBuilder margs = new ArgumentListBuilder().add("-B").add("-f", pom.getRemote());
                        FilePath localRepo = project.getLocalRepository().locate(MavenModuleSetBuild.this);
                        if(localRepo!=null)
                            margs.add("-Dmaven.repo.local="+localRepo.getRemote());

                        if (project.globalSettingConfigPath != null)
                            margs.add("-gs" , project.globalSettingConfigPath);


                       
                        // If incrementalBuild is set
                        // and the previous build didn't specify that we need a full build
                        // and we're on Maven 2.1 or later
                        // and there's at least one module listed in changedModules,
                        // then do the Maven incremental build commands.
                        // If there are no changed modules, we're building everything anyway.
                        boolean maven2_1orLater = new ComparableVersion (mavenVersion).compareTo( new ComparableVersion ("2.1") ) >= 0;
                        boolean needsFullBuild = getPreviousCompletedBuild() != null &&
                            getPreviousCompletedBuild().getAction(NeedsFullBuildAction.class) != null;
                        if (project.isIncrementalBuild() && !needsFullBuild && maven2_1orLater && !changedModules.isEmpty()) {
                            margs.add("-amd");
                            margs.add("-pl", Util.join(changedModules, ","));
                        }

                        if (project.getAlternateSettings() != null) {
                            if (IOUtils.isAbsolute(project.getAlternateSettings())) {
                                margs.add("-s").add(project.getAlternateSettings());
                            } else {
                                FilePath mrSettings = getModuleRoot().child(project.getAlternateSettings());
                                FilePath wsSettings = getWorkspace().child(project.getAlternateSettings());
                                if (!wsSettings.exists() && mrSettings.exists())
                                    wsSettings = mrSettings;
                               
                                margs.add("-s").add(wsSettings.getRemote());
                            }
                        }

                       
                        final List<MavenArgumentInterceptorAction> argInterceptors = this.getBuild().getActions(MavenArgumentInterceptorAction.class);
                       
            // find the correct maven goals and options, there might by an action overruling the defaults
                        String goals = project.getGoals(); // default
                        for (MavenArgumentInterceptorAction mavenArgInterceptor : argInterceptors) {
                          final String goalsAndOptions = mavenArgInterceptor.getGoalsAndOptions((MavenModuleSetBuild)this.getBuild());
              if(StringUtils.isNotBlank(goalsAndOptions)){
                            goals = goalsAndOptions;
                                // only one interceptor is allowed to overwrite the whole "goals and options" string
                            break;
                          }
            }
            margs.addTokenized(envVars.expand(goals));

            // enable the interceptors to change the whole command argument list
            // all available interceptors are allowed to modify the argument list
            for (MavenArgumentInterceptorAction mavenArgInterceptor : argInterceptors) {
              final ArgumentListBuilder newMargs = mavenArgInterceptor.intercept(margs, (MavenModuleSetBuild)this.getBuild());
              if (newMargs != null) {
                margs = newMargs;
              }
            }                       
                       
View Full Code Here

                ? new Maven3ProcessFactory(
                        getParent().getParent(), launcher, envVars, getMavenOpts(listener, envVars), null )
                : new MavenProcessFactory(
                        getParent().getParent(), launcher, envVars, getMavenOpts(listener, envVars), null ));

            ArgumentListBuilder margs = new ArgumentListBuilder("-N","-B");
            FilePath localRepo = mms.getLocalRepository().locate(MavenBuild.this);
            if(localRepo!=null)
                // the workspace must be on this node, so getRemote() is safe.
                margs.add("-Dmaven.repo.local="+localRepo.getRemote());

            if (mms.getAlternateSettings() != null) {
                if (IOUtils.isAbsolute(mms.getAlternateSettings())) {
                    margs.add("-s").add(mms.getAlternateSettings());
                } else {
                    FilePath mrSettings = getModuleRoot().child(mms.getAlternateSettings());
                    FilePath wsSettings = getWorkspace().child(mms.getAlternateSettings());
                    if (!wsSettings.exists() && mrSettings.exists())
                        wsSettings = mrSettings;

                    margs.add("-s").add(wsSettings.getRemote());
                }
            }


            margs.add("-f",getModuleRoot().child("pom.xml").getRemote());
            margs.addTokenized(getProject().getGoals());

            Map<String,String> systemProps = new HashMap<String, String>(envVars);
            // backward compatibility
            systemProps.put("hudson.build.number",String.valueOf(getNumber()));

            if (maven3orLater)
            {
                // FIXME here for maven 3 builds
                listener.getLogger().println("Building single Maven modules is not implemented for Maven 3, yet!");
                return Result.ABORTED;
            }
            else
            {
                boolean normalExit = false;
                try {
                    Result r = process.call(new Builder(
                        listener,new ProxyImpl(),
                        getProject(), margs.toList(), systemProps));
                    normalExit = true;
                    return r;
                } finally {
                    if(normalExitprocess.recycle();
                    else            process.discard();
View Full Code Here

            String normalizedTarget = targets
                    .substring(startIndex, endIndex)
                    .replaceAll("[\t\r\n]+"," ");

            ArgumentListBuilder args = new ArgumentListBuilder();
            MavenInstallation mi = getMaven();
            if(mi==null) {
                String execName = build.getWorkspace().act(new DecideDefaultMavenCommand(normalizedTarget));
                args.add(execName);
            } else {
                mi = mi.forNode(Computer.currentComputer().getNode(), listener);
              mi = mi.forEnvironment(env);
                String exec = mi.getExecutable(launcher);
                if(exec==null) {
                    listener.fatalError(Messages.Maven_NoExecutable(mi.getHome()));
                    return false;
                }
                args.add(exec);
            }
            if(pom!=null)
                args.add("-f",pom);

            Set<String> sensitiveVars = build.getSensitiveBuildVariables();

            args.addKeyValuePairs("-D",build.getBuildVariables(),sensitiveVars);
            args.addKeyValuePairsFromPropertyString("-D",properties,vr,sensitiveVars);
            if (usesPrivateRepository())
                args.add("-Dmaven.repo.local=" + build.getWorkspace().child(".repository"));
            args.addTokenized(normalizedTarget);
            wrapUpArguments(args,normalizedTarget,build,launcher,listener);

            buildEnvVars(env, mi);

            try {
View Full Code Here

        }
    }
   
   
    private ArgumentListBuilder buildJnlpArgs(Computer c) throws Exception {
        ArgumentListBuilder args = new ArgumentListBuilder();
        args.add(new File(new File(System.getProperty("java.home")),"bin/java").getPath(),"-jar");
        args.add(Which.jarFile(netx.jnlp.runtime.JNLPRuntime.class).getAbsolutePath());
        args.add("-headless","-basedir");
        args.add(createTmpDir());
        args.add("-nosecurity","-jnlp", getJnlpLink(c));
        return args;
    }
View Full Code Here

                return newLocalChannel();

            String javaExe = System.getProperty("java.home") + "/bin/java";
            File slaveJar = Which.jarFile(Launcher.class);

            ArgumentListBuilder args = new ArgumentListBuilder().add(javaExe);
            if(slaveJar.isFile())
                args.add("-jar").add(slaveJar);
            else // in production code this never happens, but during debugging this is convenientud   
                args.add("-cp").add(slaveJar).add(hudson.remoting.Launcher.class.getName());

            if(rootPassword==null) {
                // try sudo, in the hope that the user has the permission to do so without password
                return new LocalLauncher(listener).launchChannel(
                        args.prepend(sudoExe()).toCommandArray(),
                        listener.getLogger(), null, Collections.<String, String>emptyMap());
            } else {
                // try sudo with the given password. Also run in pfexec so that we can elevate the privileges
                Process proc = sudoWithPass(args);
                return Channels.forProcess(args.toStringWithQuote(), Computer.threadPoolForRemoting, proc,
                        listener.getLogger() );
            }
        }
View Full Code Here

                - http://java.sun.com/j2se/1.5.0/sdksilent.html
                - http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/silent.html
             */
            String logFile = jdkBundle+".install.log";

            ArgumentListBuilder args = new ArgumentListBuilder();
            args.add(jdkBundle);
            if (isJava15() || isJava14()) {
                args.add("/s","/v/qn REBOOT=ReallySuppress INSTALLDIR=\\\""+ expectedLocation +"\\\" /L \\\""+logFile+"\\\"");
            } else {
                // modern version supports arguments in more sane format.
                args.add("/s","/v","/qn","/L","\\\""+logFile+"\\\"","REBOOT=ReallySuppress","INSTALLDIR=\\\""+ expectedLocation+"\\\"");
            }
            // according to http://community.acresso.com/showthread.php?t=83301, \" is the trick to quote values with whitespaces.
            // Oh Windows, oh windows, why do you have to be so difficult?
            int r = launcher.launch().cmds(args).stdout(out)
                    .pwd(new FilePath(launcher.getChannel(), expectedLocation)).join();
View Full Code Here

                bundle.copyRecursiveTo(appDir);
            } else {
                throw new IOException("Expected either a .app or .ipa bundle!");
            }

            ArgumentListBuilder arguments = new ArgumentListBuilder(fruitstrap.getRemote());
            arguments.add("--id", deviceId, "--bundle", appDir.getName());

            ProcStarter proc = new LocalLauncher(listener).launch()
                    .cmds(arguments)
                    .stdout(listener)
                    .pwd(appDir.getParent());
View Full Code Here

    public void fetch(String repository, String refspec) throws GitException {
        listener.getLogger().println(
            "Fetching upstream changes"
                + (repository != null ? " from " + repository : ""));

        ArgumentListBuilder args = new ArgumentListBuilder();
        args.add("fetch", "-t");

        if (repository != null) {
            args.add(repository);
            if (refspec != null) {
                args.add(refspec);
            }
        }

        launchCommand(args);
    }
View Full Code Here

TOP

Related Classes of hudson.util.ArgumentListBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.