First you have these objects, usually taken as parameters for the perform method:
Launcher launcher; AbstractBuild<?, ?> build; BuildListener listener;
Then you created and added the arguments to the ListBuilder argument, perhaps something like:
ArgumentListBuilder command = new ArgumentListBuilder(); command.addTokenized("xcopy /?");
Then do something like:
ProcStarter ps = launcher.new ProcStarter(); ps = ps.cmds(command).stdout(listener); ps = ps.pwd(build.getWorkspace()).envs(build.getEnvironment(listener)); Proc proc = launcher.launch(ps); int retcode = proc.join();
ProcStarter will execute the command in the node specified by the launcher instance. But please, at least take a look at the javadocs of all the above classes before using, the above is not a direct copy-paste from the working code.
source share