All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.cli.SetBuildDescriptionCommand Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 *
 * Copyright (c) 2004-2010 Oracle Corporation.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     
 *
 *******************************************************************************/ 

package hudson.cli;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Run;
import hudson.remoting.Callable;

import java.io.IOException;
import java.io.Serializable;

import org.apache.commons.io.IOUtils;
import org.kohsuke.args4j.Argument;

@Extension
public class SetBuildDescriptionCommand extends CLICommand implements Serializable {

    @Override
    public String getShortDescription() {
        return "Sets the description of a build";
    }

    @Argument(metaVar="JOB",usage="Name of the job to build",required=true,index=0)
    public transient AbstractProject job;

    @Argument(metaVar="BUILD#",usage="Number of the build",required=true,index=1)
    public int number;
    
    @Argument(metaVar="DESCRIPTION",required=true,usage="Description to be set. '=' to read from stdin.", index=2)
    public String description;

    protected int run() throws Exception {
    	Run run = job.getBuildByNumber(number);
        run.checkPermission(Run.UPDATE);

        if ("=".equals(description)) {
        	description = channel.call(new Callable() {
				public String call() throws IOException {
					return IOUtils.toString(System.in);
				}
        	});
        }
        
        run.setDescription(description);
        
        return 0;
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy