本文整理汇总了Java中hudson.Launcher.ProcStarter类的典型用法代码示例。如果您正苦于以下问题:Java ProcStarter类的具体用法?Java ProcStarter怎么用?Java ProcStarter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcStarter类属于hudson.Launcher包,在下文中一共展示了ProcStarter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readFromProcess
import hudson.Launcher.ProcStarter; //导入依赖的package包/类
/**
* Executes a command and reads the result to a string. It uses the launcher to run the command to make sure the
* launcher decorator is used ie. docker.image step
*
* @param args command arguments
* @return output from the command
* @throws InterruptedException if interrupted
*/
@Nullable
private String readFromProcess(String... args) throws InterruptedException {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
ProcStarter ps = launcher.launch();
Proc p = launcher.launch(ps.cmds(args).stdout(baos));
int exitCode = p.join();
if (exitCode == 0) {
return baos.toString(getComputer().getDefaultCharset().name()).replaceAll("[\t\r\n]+", " ").trim();
} else {
return null;
}
} catch (IOException e) {
e.printStackTrace(console.format("Error executing command '%s' : %s%n", Arrays.toString(args), e.getMessage()));
}
return null;
}
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:25,代码来源:WithMavenStepExecution.java
示例2: executeTest
import hudson.Launcher.ProcStarter; //导入依赖的package包/类
/**
* Used to execute/start a remote process that initializes the testing
* process.
*
* @param build
* the current build
* @param listener
* the build's listener
* @param entry
* containing the {@link Node} and its {@link EnvVars}
* @return the started process
* @throws InterruptedException
* @throws IOException
* @since 1.0
*/
private Proc executeTest(AbstractBuild<?, ?> build, BuildListener listener,
Entry<Node, EnvVars> entry) throws InterruptedException,
IOException {
final EnvVars vars = NodeUtils.getEnvironment(entry.getKey(),
entry.getValue());
final Node node = entry.getKey();
// Get testing environment on the specific node
FilePath testEnv = FilePathUtils.getPathToTestEnvOnNode(node, build);
// Create a remote launcher
RemoteLauncher remoteLaucher = new RemoteLauncher(listener,
node.getChannel(), true);
// Create process starter
ProcStarter starter = remoteLaucher.launch()
.cmds(buildShellCmds(vars, node, build)).stdout(listener)
.stderr(listener.getLogger()).pwd(testEnv.getParent());
// Launch the process
Proc proc = remoteLaucher.launch(starter);
return proc;
}
开发者ID:bombardier-transportation,项目名称:distributed-test-job,代码行数:40,代码来源:DTBuilder.java
示例3: execute
import hudson.Launcher.ProcStarter; //导入依赖的package包/类
/**
* Execute a Drush command.
*/
protected boolean execute(ArgumentListBuilder args, TaskListener out) throws IOException, InterruptedException {
ProcStarter starter = launcher.launch().pwd(workspace).cmds(args);
if (out == null) {
// Output stdout/stderr into listener.
starter.stdout(listener);
} else {
// Output stdout into out.
// Do not output stderr since this breaks the XML formatting on stdout.
starter.stdout(out).stderr(NullOutputStream.NULL_OUTPUT_STREAM);
}
starter.join();
return true;
}
开发者ID:jenkinsci,项目名称:drupal-developer-plugin,代码行数:17,代码来源:DrushInvocation.java
示例4: commandsEscaping
import hudson.Launcher.ProcStarter; //导入依赖的package包/类
@Test
public void commandsEscaping() {
ProcStarter procStarter = new DummyLauncher(null).launch();
procStarter = procStarter.cmds("$$$$", "$$?");
String[] commands = ContainerExecDecorator.getCommands(procStarter);
assertArrayEquals(new String[] { "\\$\\$", "\\$?" }, commands);
}
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:8,代码来源:ContainerExecDecoratorTest.java
示例5: execCommand
import hudson.Launcher.ProcStarter; //导入依赖的package包/类
private ProcReturn execCommand(boolean quiet, String... cmd) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Launcher launcher = decorator
.decorate(new DummyLauncher(new StreamTaskListener(new TeeOutputStream(out, System.out))), null);
ContainerExecProc proc = (ContainerExecProc) launcher
.launch(launcher.new ProcStarter().pwd("/tmp").cmds(cmd).quiet(quiet));
// wait for proc to finish (shouldn't take long)
while (proc.isAlive()) {
Thread.sleep(100);
}
assertFalse("proc is alive", proc.isAlive());
int exitCode = proc.joinWithTimeout(10, TimeUnit.SECONDS, StreamTaskListener.fromStderr());
return new ProcReturn(proc, exitCode, out.toString());
}
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:15,代码来源:ContainerExecDecoratorTest.java
注:本文中的hudson.Launcher.ProcStarter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论