本文整理了Java中hudson.Proc
类的一些代码示例,展示了Proc
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Proc
类的具体详情如下:
包路径:hudson.Proc
类名称:Proc
[英]External process wrapper.
Used for launching, monitoring, waiting for a process.
[中]外部进程包装器。
用于启动、监视、等待进程。
代码示例来源:origin: jenkinsci/jenkins
/**
* Reports the exit code from the process.
*
* This allows subtypes to treat the exit code differently (for example by treating non-zero exit code
* as if it's zero, or to set the status to {@link Result#UNSTABLE}). Any non-zero exit code will cause
* the build step to fail. Use {@link #isErrorlevelForUnstableBuild(int exitCode)} to redefine the default
* behaviour.
*
* @since 1.549
*/
protected int join(Proc p) throws IOException, InterruptedException {
return p.join();
}
代码示例来源:origin: jenkinsci/jenkins
public void kill() throws IOException, InterruptedException {
p.kill();
}
代码示例来源:origin: jenkinsci/jenkins
final Proc procHolderForJoin = start();
LOGGER.log(Level.FINER, "Started the process {0}", procHolderForJoin);
return procHolderForJoin.join();
} else {
final int returnCode = procHolderForJoin.join();
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.log(Level.FINER, "Process {0} has finished with the return code {1}", new Object[]{procHolderForJoin, returnCode});
if (procHolderForJoin.isAlive()) { // Should never happen but this forces Proc to not be removed and early GC by escape analysis
LOGGER.log(Level.WARNING, "Process {0} has not finished after the join() method completion", procHolderForJoin);
代码示例来源:origin: jenkinsci/jenkins
public IOTriplet getIOtriplet() {
IOTriplet r = new IOTriplet();
if (reverseStdout) r.stdout = new RemoteInputStream(p.getStdout());
if (reverseStderr) r.stderr = new RemoteInputStream(p.getStderr());
if (reverseStdin) r.stdin = new RemoteOutputStream(p.getStdin());
return r;
}
});
代码示例来源:origin: jenkinsci/subversion-plugin
/**
* Subversion externals to a file. Requires 1.6 workspace.
*/
@Issue("JENKINS-7539")
@Test
public void externalsToFile() throws Exception {
Proc server = runSvnServe(getClass().getResource("HUDSON-7539.zip"));
try {
// enable 1.6 mode
HtmlForm f = r.createWebClient().goTo("configure").getFormByName("config");
f.getSelectByName("svn.workspaceFormat").setSelectedAttribute("10",true);
r.submit(f);
FreeStyleProject p = r.createFreeStyleProject();
p.setScm(new SubversionSCM("svn://localhost/dir1"));
FreeStyleBuild b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
assertTrue(b.getWorkspace().child("2").exists());
assertTrue(b.getWorkspace().child("3").exists());
assertTrue(b.getWorkspace().child("test.x").exists());
r.assertBuildStatusSuccess(p.scheduleBuild2(0));
} finally {
server.kill();
}
}
代码示例来源:origin: jenkinsci/subversion-plugin
@Issue("JENKINS-777")
@Test
public void ignoreExternals() throws Exception {
Proc p = runSvnServe(getClass().getResource("JENKINS-777.zip"));
try {
FreeStyleProject b = r.createFreeStyleProject();
ModuleLocation[] locations = {
new ModuleLocation("svn://localhost/jenkins-777/proja", "no_externals", "infinity", true),
new ModuleLocation("svn://localhost/jenkins-777/proja", "with_externals", "infinity", false)
};
b.setScm(new SubversionSCM(Arrays.asList(locations), new CheckoutUpdater(), null, null, null, null, null, null));
FreeStyleBuild build = r.assertBuildStatusSuccess(b.scheduleBuild2(0));
FilePath ws = build.getWorkspace();
// Check that the external exists
assertTrue(ws.child("with_externals").child("externals").child("projb").exists());
// Check that the external doesn't exist
assertTrue(!(ws.child("no_externals").child("externals").child("projb").exists()));
} finally {
p.kill();
}
}
代码示例来源:origin: jenkinsci/subversion-plugin
@Issue("JENKINS-1379")
@Test
public void superUserForAllRepos() throws Exception {
Proc p = runSvnServe(getClass().getResource("HUDSON-1379.zip"));
try {
SystemCredentialsProvider.getInstance().setDomainCredentialsMap(Collections.singletonMap(Domain.global(),
Arrays.<Credentials>asList(
new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "1-alice", null, "alice","alice")
)
));
FreeStyleProject b = r.createFreeStyleProject();
b.setScm(new SubversionSCM("svn://localhost/bob"));
FreeStyleProject c = r.createFreeStyleProject();
c.setScm(new SubversionSCM("svn://localhost/charlie"));
// should fail without a credential
r.assertBuildStatus(Result.FAILURE,b.scheduleBuild2(0).get());
r.assertBuildStatus(Result.FAILURE,c.scheduleBuild2(0).get());
b.setScm(new SubversionSCM("svn://localhost/bob", "1-alice", "."));
c.setScm(new SubversionSCM("svn://localhost/charlie", "1-alice", "."));
// but with the super user credential both should work now
r.buildAndAssertSuccess(b);
r.buildAndAssertSuccess(c);
} finally {
p.kill();
}
}
代码示例来源:origin: jenkinsci/subversion-plugin
/**
* Used for experimenting the memory leak problem.
* This test by itself doesn't detect that, but I'm leaving it in anyway.
*/
@Issue("JENKINS-8061")
@Test
public void pollingLeak() throws Exception {
Proc p = runSvnServe(getClass().getResource("small.zip"));
try {
FreeStyleProject b = r.createFreeStyleProject();
b.setScm(new SubversionSCM("svn://localhost/"));
b.setAssignedNode(r.createSlave());
r.assertBuildStatusSuccess(b.scheduleBuild2(0));
b.poll(new StreamTaskListener(System.out,Charset.defaultCharset()));
} finally {
p.kill();
}
}
代码示例来源:origin: openshift/jenkins-client-plugin
Launcher.ProcStarter ps = launcher.launch().cmds(Arrays.asList(command)).envs(envVars).pwd(filePath).quiet(true).stdout(outBuf).stderr(errBuf);
proc = ps.start();
long reCheckSleep = 250;
int outputSize = 0;
while (proc.isAlive()) {
Thread.sleep(reCheckSleep);
int rc = proc.join();
outBuf.flush();
errBuf.flush();
if (proc != null && proc.isAlive()) {
proc.kill();
代码示例来源:origin: org.jvnet.hudson.main/maven3-plugin
.cmds(args)
.envs(env)
.pwd(build.getWorkspace())
.stdout(buffer)
.start();
int result = process.joinWithTimeout(timeout, timeoutUnit, listener);
throw new AbortException(
format("Failed to determine Maven 3 installation version;" +
" unexpected exit code: %d, command output: %s", process.join(), output));
代码示例来源:origin: jenkinsci/subversion-plugin
FreeStyleProject p = r.createFreeStyleProject();
SubversionSCM scm = new SubversionSCM("svn://localhost/");
scm.setWorkspaceUpdater(new UpdateWithCleanUpdater());
p.setScm(scm);
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FreeStyleBuild b = r.buildAndAssertSuccess(p);
p.getBuildersList().clear();
b = r.buildAndAssertSuccess(p);
System.out.println(b.getLog());
assertFalse(ws.child("c").exists());
} finally {
srv.kill();
代码示例来源:origin: jenkinsci/subversion-plugin
/**
* There was a bug that credentials stored in the remote call context was serialized wrongly.
*/
@Issue("JENKINS-8061")
@Test
public void remoteBuild() throws Exception {
Proc p = runSvnServe(SubversionSCMTest.class.getResource("HUDSON-1379.zip"));
try {
SystemCredentialsProvider.getInstance().setDomainCredentialsMap(Collections.singletonMap(Domain.global(),
Arrays.<Credentials>asList(
new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "1-alice", null, "alice", "alice")
)
));
FreeStyleProject b = r.createFreeStyleProject();
b.setScm(new SubversionSCM("svn://localhost/bob", "1-alice", "."));
b.setAssignedNode(r.createSlave());
FreeStyleBuild run = r.buildAndAssertSuccess(b);
/* TODO runSvnServe not guaranteed to use port 3690; otherwise this works:
assertLogContains(Messages.CredentialsSVNAuthenticationProviderImpl_sole_credentials("alice/******", "<svn://localhost:3690> 8a677b3a-1c61-4b23-9212-1bf3c3d713a7"), run);
*/
} finally {
p.kill();
}
}
}
代码示例来源:origin: jenkinsci/mercurial-plugin
/**
* For use with {@link #launch} (or similar) when running commands not inside a build and which therefore might not be easily killed.
*/
public static int joinWithPossibleTimeout(ProcStarter proc, boolean useTimeout, final TaskListener listener) throws IOException, InterruptedException {
return useTimeout ? proc.start().joinWithTimeout(60 * 60, TimeUnit.SECONDS, listener) : proc.join();
}
代码示例来源:origin: jenkinsci/fitnesse-plugin
private void killProc(Proc proc) {
if (proc != null) {
try {
proc.kill();
for (int i = 0; i < 4; ++i) {
if (proc.isAlive())
Thread.sleep(SLEEP_MILLIS);
}
} catch (Exception e) {
e.printStackTrace(logger);
}
}
}
代码示例来源:origin: jenkinsci/comments-remover-plugin
private void runProcess(Proc process, TaskListener listener) throws IOException, InterruptedException {
if (getDescriptor().getVerboseMode()) {
/* Read the process's output */
String inputLine;
BufferedReader in = new BufferedReader(new InputStreamReader(process.getStdout(), StandardCharsets.UTF_8));
while ((inputLine = in.readLine()) != null) {
listener.getLogger().println(inputLine);
}
in.close();
}
process.joinWithTimeout(60, TimeUnit.SECONDS, listener);
}
代码示例来源:origin: jenkinsci/android-emulator-plugin
while (System.currentTimeMillis() < start + timeout && (ignoreProcess || emu.process().isAlive())) {
ByteArrayOutputStream stream = new ByteArrayOutputStream(16);
Proc proc = emu.getProcStarter(bootCheckCmd).stdout(stream).start();
int retVal = proc.joinWithTimeout(adbTimeout, TimeUnit.MILLISECONDS, emu.launcher().getListener());
if (retVal == 0) {
代码示例来源:origin: jenkinsci/android-emulator-plugin
.getSdkInstallAndUpdateCommand(proxySettings, components);
ArgumentListBuilder cmd = Utils.getToolCommand(sdk, launcher.isUnix(), sdkInstallAndUpdateCmd);
ProcStarter procStarter = launcher.launch().stderr(logger).readStdout().writeStdin().cmds(cmd);
Proc proc = procStarter.start();
BufferedReader r = new BufferedReader(new InputStreamReader(proc.getStdout()));
try {
String line;
while (proc.isAlive() && (line = r.readLine()) != null) {
logger.println(line);
if (line.toLowerCase(Locale.ENGLISH).startsWith("license id: ") ||
line.toLowerCase(Locale.ENGLISH).startsWith("license android-sdk")) {
proc.getStdin().write("y\r\n".getBytes());
proc.getStdin().flush();
代码示例来源:origin: jenkinsci/jenkins
public boolean isAlive() throws IOException, InterruptedException {
return p.isAlive();
}
代码示例来源:origin: jenkinsci/git-client-plugin
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "earlier readStderr()/readStdout() call prevents null return")
private String readProcessIntoString(Proc process, String encoding, boolean useStderr)
throws IOException, UnsupportedEncodingException {
if (useStderr) {
/* process.getStderr reference is the findbugs warning to be suppressed */
return IOUtils.toString(process.getStderr(), encoding);
}
/* process.getStdout reference is the findbugs warning to be suppressed */
return IOUtils.toString(process.getStdout(), encoding);
}
代码示例来源:origin: jenkinsci/debian-package-builder-plugin
public String runCommandForOutput(String command) throws DebianizingException {
try {
String actualCommand = MessageFormat.format("bash -c ''{0}''", command);
return CharStreams.toString(new InputStreamReader(launcher.launch().cmdAsSingleString(actualCommand).readStdout().start().getStdout()));
} catch (IOException e) {
e.printStackTrace(listener.getLogger());
throw new DebianizingException(MessageFormat.format("Command <{0}> failed", command), e);
}
}
内容来源于网络,如有侵权,请联系作者删除!