Package hudson.util

Examples of hudson.util.StreamTaskListener


    public void call(RemoteCall remoteCall) throws PerforceException {
        try {
            // ensure we actually have a valid hudson launcher
            if (null == hudsonLauncher) {
                hudsonLauncher = Hudson.getInstance().createLauncher(new StreamTaskListener(System.out));
            }
            TaskListener listener = hudsonLauncher.getListener();

            // hudsonOut->p4in->reader
            FastPipedOutputStream hudsonOut = new FastPipedOutputStream();
View Full Code Here


            if (!(p instanceof TopLevelItem)) continue;
            if (p.isDisabled()) continue;
            if (p.getScm() instanceof PerforceSCM) {
                LOGGER.finer("Checking " + p.getName() + "'s Perforce SCM for " + perforceId + "'s address.");
                PerforceSCM pscm = (PerforceSCM) p.getScm();
                TaskListener listener = new StreamTaskListener(System.out);
                Node node = p.getLastBuiltOn();

                // If the node is offline, skip the project.
                // The node needs to be online for us to execute commands.
                if (node == null) {
                    LOGGER.finer("Build doesn't seem to have been run before. Cannot resolve email address using this project.");
                    continue;
                }
                if (node.getChannel() == null) {
                    LOGGER.finer("Node " + node.getDisplayName() + " is not up, cannot resolve email address using this project.");
                    continue;
                }
                // TODO: replace this with p.getLastBuild().getWorkspace()
                // which is the way it should be, but doesn't work with this version of hudson.
                for (int tries = 0; tries < 5; tries++) {
                    FilePath workspace = p.getLastBuiltOn().getRootPath();
                    Launcher launcher = p.getLastBuiltOn().createLauncher(listener);
                    com.tek42.perforce.model.User pu = null;
                    try {
                        LOGGER.finer("Trying to get email address from perforce for " + perforceId);
                        pu = pscm.getDepot(launcher, workspace, p, null, node).getUsers().getUser(perforceId);
                        if (pu != null && pu.getEmail() != null && !pu.getEmail().equals("")) {
                            LOGGER.fine("Got email (" + pu.getEmail() + ") from perforce for " + perforceId);
                            return pu.getEmail();
                        } else {
                            //operation succeeded, but no email address was found for this user
                            return null;
                        }
                    } catch (Exception e) {
                        LOGGER.fine("Could not get email address from Perforce: " + e.getMessage());
                        e.printStackTrace(listener.getLogger());
                    }
                    try {
                        //gradually increase sleep time
                        Thread.sleep(tries);
                    } catch (InterruptedException e){
View Full Code Here

    public void exec(String[] cmd) throws PerforceException {
        try {
      // ensure we actually have a valid hudson launcher
      if (null == hudsonLauncher) {
        hudsonLauncher = Hudson.getInstance().createLauncher(new StreamTaskListener(System.out));
      }

            // hudsonOut->p4in->reader
            HudsonPipedOutputStream hudsonOut = new HudsonPipedOutputStream();
            FastPipedInputStream p4in = new FastPipedInputStream(hudsonOut);
View Full Code Here

        FilePath workspace = build.getWorkspace();
        String effectiveP4Client = this.p4Client;
        try {
            effectiveP4Client = getEffectiveClientName(effectiveP4Client, build);
        } catch (Exception e) {
            new StreamTaskListener(System.out).getLogger().println(
                    "Could not get effective client name: " + e.getMessage());
        }
        effectiveP4Client = MacroStringHelper.substituteParameters(effectiveP4Client, this, build, env);
        return effectiveP4Client;
    }
View Full Code Here

        Logger perforceLogger = Logger.getLogger(PerforceSCM.class.getName());
        perforceLogger.info(
            "Workspace '"+workspace.getRemote()+"' is being deleted; flushing workspace to revision 0.");
        TaskListener loglistener = new LogTaskListener(perforceLogger,Level.INFO);
        PrintStream log = loglistener.getLogger();
        TaskListener listener = new StreamTaskListener(log);
        Launcher launcher = node.createLauncher(listener);
       
        try {
            Depot depot = getDepot(launcher, workspace, project, null, node);
            final String effectiveProjectPath = MacroStringHelper.substituteParameters(
View Full Code Here

    public void exec(String[] cmd) throws PerforceException {
        try {
            // ensure we actually have a valid hudson launcher
            if (null == hudsonLauncher) {
                hudsonLauncher = Hudson.getInstance().createLauncher(new StreamTaskListener(System.out));
            }
            VirtualChannel channel = hudsonLauncher.getChannel();

            // hudsonOut->p4in->reader
            FastPipedOutputStream hudsonOut = new FastPipedOutputStream();
View Full Code Here

                    // TODO: use the default charset of the contextual Computer object
                    la = new LogActionImpl(getNode(), Charset.defaultCharset());
                    getNode().addAction(la);
                }

                listener = new StreamTaskListener(new FileOutputStream(la.getLogFile(), true));
            }
            return key.cast(listener);
        } else if (Node.class.isAssignableFrom(key)) {
            Computer c = get(Computer.class);
            Node n = null;
View Full Code Here

                        Computer.threadPoolForRemoting.submit(new Callable<Node>() {
                            public Node call() throws Exception {
                                // TODO: record the output somewhere
                                DockerSlave slave = null;
                                try {
                                    slave = t.provision(new StreamTaskListener(System.out));
                                    Jenkins.getInstance().addNode(slave);
                                    // Docker instances may have a long init script. If we declare
                                    // the provisioning complete by returning without the connect
                                    // operation, NodeProvisioner may decide that it still wants
                                    // one more instance, because it sees that (1) all the slaves
View Full Code Here

    public void onPost(String triggeredByUser) {
        final String pushBy = triggeredByUser;
        getDescriptor().queue.execute(new Runnable() {
            private boolean runPolling() {
                try {
                    StreamTaskListener listener = new StreamTaskListener(getLogFile());

                    try {
                        PrintStream logger = listener.getLogger();
                        long start = System.currentTimeMillis();
                        logger.println("Started on "+ DateFormat.getDateTimeInstance().format(new Date()));
                        boolean result = job.poll(listener).hasChanges();
                        logger.println("Done. Took "+ Util.getTimeSpanString(System.currentTimeMillis()-start));
                        if(result)
                            logger.println("Changes found");
                        else
                            logger.println("No changes");
                        return result;
                    } catch (Error e) {
                        e.printStackTrace(listener.error("Failed to record SCM polling"));
                        LOGGER.log(Level.SEVERE,"Failed to record SCM polling",e);
                        throw e;
                    } catch (RuntimeException e) {
                        e.printStackTrace(listener.error("Failed to record SCM polling"));
                        LOGGER.log(Level.SEVERE,"Failed to record SCM polling",e);
                        throw e;
                    } finally {
                        listener.close();
                    }
                } catch (IOException e) {
                    LOGGER.log(Level.SEVERE,"Failed to record SCM polling",e);
                }
                return false;
View Full Code Here

     
  private final TaskListener taskListener;
 
    public VirtualMachineSlaveComputer(Slave slave) {
        super(slave);   
        this.taskListener = new StreamTaskListener(new ReopenableRotatingFileOutputStream(getLogFile(),10));
    }
View Full Code Here

TOP

Related Classes of hudson.util.StreamTaskListener

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.