KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > tasks > BatchFile


1 package hudson.tasks;
2
3 import hudson.FilePath;
4 import hudson.Launcher;
5 import hudson.Util;
6 import hudson.model.Build;
7 import hudson.model.BuildListener;
8 import hudson.model.Descriptor;
9 import hudson.model.Project;
10 import org.kohsuke.stapler.StaplerRequest;
11
12 import java.io.IOException JavaDoc;
13
14 /**
15  * Executes commands by using Windows batch file.
16  *
17  * @author Kohsuke Kawaguchi
18  */

19 public class BatchFile extends CommandInterpreter {
20     public BatchFile(String JavaDoc command) {
21         super(command);
22     }
23
24     protected String JavaDoc[] buildCommandLine(FilePath script) {
25         return new String JavaDoc[] {script.getRemote()};
26     }
27
28     protected String JavaDoc getContents() {
29         return command+"\r\nexit %ERRORLEVEL%";
30     }
31
32     protected String JavaDoc getFileExtension() {
33         return ".bat";
34     }
35
36     public Descriptor<Builder> getDescriptor() {
37         return DESCRIPTOR;
38     }
39
40     public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
41
42     public static final class DescriptorImpl extends Descriptor<Builder> {
43         private DescriptorImpl() {
44             super(BatchFile.class);
45         }
46
47         public String JavaDoc getHelpFile() {
48             return "/help/project-config/batch.html";
49         }
50
51         public String JavaDoc getDisplayName() {
52             return "Execute Windows batch command";
53         }
54
55         public Builder newInstance(StaplerRequest req) {
56             return new BatchFile(req.getParameter("batchFile"));
57         }
58     }
59 }
60
Popular Tags