本文整理汇总了Java中hudson.tasks.Shell类的典型用法代码示例。如果您正苦于以下问题:Java Shell类的具体用法?Java Shell怎么用?Java Shell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Shell类属于hudson.tasks包,在下文中一共展示了Shell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRecorderNoFile
import hudson.tasks.Shell; //导入依赖的package包/类
/**
* Test that when "marathon.json" is not present the build is failed
* and no requests are made to the configured Marathon instance.
*
* @throws Exception
*/
@Test
public void testRecorderNoFile() throws Exception {
final FreeStyleProject project = j.createFreeStyleProject();
project.getBuildersList().add(new Shell("echo hello"));
// add recorder
project.getPublishersList().add(new MarathonRecorder(TestUtils.getHttpAddresss(httpServer)));
// run a build with the shell step and recorder publisher
final FreeStyleBuild build = j.assertBuildStatus(Result.FAILURE, project.scheduleBuild2(0).get());
// assert things
j.assertLogContains("[Marathon]", build);
j.assertLogContains("marathon.json", build);
assertEquals("No web requests were made", 0, httpServer.getRequestCount());
}
示例2: pickFirstErrorBuildIfPreferringErrors
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void pickFirstErrorBuildIfPreferringErrors() throws Exception {
FreeStyleProject project = createProject(0, true);
Shell exitShell = new Shell("exit 1");
project.getBuildersList().add(exitShell);
project.scheduleBuild2(0).waitForStart().run();
project.scheduleBuild2(0).waitForStart().run();
project.getBuildersList().remove(exitShell);
FreeStyleBuild successfulBuildAfterFailures = project.scheduleBuild2(0).get();
String logText = FileUtils.readFileToString(successfulBuildAfterFailures.getLogFile());
assertEquals(logText, Result.SUCCESS, successfulBuildAfterFailures.getResult());
FreeStyleBuild completedBuild = project.scheduleBuild2(0).get();
logText = FileUtils.readFileToString(completedBuild.getLogFile());
assertThatVmIsInText(completedBuild.getNumber(), 2, logText);
}
示例3: testSendBuildData
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void testSendBuildData() throws Exception {
ArgumentCaptor<HttpRequest> captor = ArgumentCaptor.forClass(HttpRequest.class);
FreeStyleProject project = j.createFreeStyleProject();
project.getBuildersList().add(new Shell("Echo Hello"));
project.getBuildersList().add(new Shell("Echo Hello2"));
project.getBuildersList().add(new Shell("Echo Hello3"));
project.getBuildersList().add(new Shell("Echo Hello4"));
project.getPublishersList().add(new SumoBuildNotifier());
FreeStyleBuild build = project.scheduleBuild2(0).get();
Mockito.verify(handler, atLeast(1)).handle(
captor.capture(),
Mockito.isA(HttpResponse.class),
Mockito.isA(HttpContext.class));
HttpEntityEnclosingRequest request = (HttpEntityEnclosingRequest) captor.getValue();
Assert.assertTrue("Message too short.", ModelFactory.createBuildModel(build).toJson().length() <= request.getEntity().getContentLength());
}
示例4: call
import hudson.tasks.Shell; //导入依赖的package包/类
@Override
public Boolean call() throws Throwable {
final Jenkins jenkins = Jenkins.getInstance();
// prepare job
final FreeStyleProject project = jenkins.createProject(FreeStyleProject.class, "freestyle-project");
final Shell env = new Shell("env");
project.getBuildersList().add(env);
project.setAssignedLabel(new LabelAtom(DOCKER_CLOUD_LABEL));
project.save();
LOG.trace("trace test.");
project.scheduleBuild(new TestCause());
// image pull may take time
waitUntilNoActivityUpTo(jenkins, 10 * 60 * 1000);
final FreeStyleBuild lastBuild = project.getLastBuild();
assertThat(lastBuild, not(nullValue()));
assertThat(lastBuild.getResult(), is(Result.SUCCESS));
assertThat(getLog(lastBuild), Matchers.containsString(TEST_VALUE));
assertThat(getLog(lastBuild), Matchers.containsString(CLOUD_ID + "=" + DOCKER_CLOUD_NAME));
return true;
}
示例5: testWrapper
import hudson.tasks.Shell; //导入依赖的package包/类
@Ignore("For local experiments")
@Test
public void testWrapper() throws Exception {
final FreeStyleProject project = jRule.createProject(FreeStyleProject.class, "freestyle");
final DockerConnector connector = new DockerConnector("tcp://" + ADDRESS + ":2376/");
connector.setConnectorType(JERSEY);
final DockerSlaveConfig config = new DockerSlaveConfig();
config.getDockerContainerLifecycle().setImage("java:8-jdk-alpine");
config.setLauncher(new NoOpDelegatingComputerLauncher(new DockerComputerSingleJNLPLauncher()));
config.setRetentionStrategy(new DockerOnceRetentionStrategy(10));
final DockerSimpleBuildWrapper dockerSimpleBuildWrapper = new DockerSimpleBuildWrapper(connector, config);
project.getBuildWrappersList().add(dockerSimpleBuildWrapper);
project.getBuildersList().add(new Shell("sleep 30"));
final QueueTaskFuture<FreeStyleBuild> taskFuture = project.scheduleBuild2(0);
jRule.waitUntilNoActivity();
jRule.pause();
}
示例6: testFilePlainWithFailureAndUpload
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void testFilePlainWithFailureAndUpload() throws Exception {
forFailedJobs = true;
underTest = new GoogleCloudStorageUploader(CREDENTIALS_ID,
ImmutableList.<AbstractUpload>of(setOptionalParams(
new ClassicUpload(bucket, new MockUploadModule(executor),
glob, null /* legacy arg */, null /* legacy arg */))));
project.getBuildersList().add(new Shell("echo foo > bar.txt"));
// Fail the build to show that the uploader does nothing.
project.getBuildersList().add(new FailureBuilder());
project.getPublishersList().add(underTest);
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.passThruWhen(Storage.Buckets.Insert.class);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
FreeStyleBuild build = project.scheduleBuild2(0).get();
assertEquals(Result.FAILURE, build.getResult());
}
示例7: testStdoutUpload
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void testStdoutUpload() throws Exception {
underTest = new GoogleCloudStorageUploader(CREDENTIALS_ID,
ImmutableList.<AbstractUpload>of(
setOptionalParams(
new StdoutUpload(bucket, new MockUploadModule(executor),
"build-log.txt", null /* legacy arg */))));
project.getBuildersList().add(new Shell("echo Hello World!"));
project.getPublishersList().add(underTest);
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.passThruWhen(Storage.Buckets.Insert.class);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
FreeStyleBuild build = project.scheduleBuild2(0).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例8: testFileGlob
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void testFileGlob() throws Exception {
glob = "*.txt";
underTest = new GoogleCloudStorageUploader(CREDENTIALS_ID,
ImmutableList.<AbstractUpload>of(setOptionalParams(
new ClassicUpload(bucket, new MockUploadModule(executor),
glob, null /* legacy arg */, null /* legacy arg */))));
project.getBuildersList().add(new Shell("echo foo > bar.txt"));
project.getPublishersList().add(underTest);
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.passThruWhen(Storage.Buckets.Insert.class);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
FreeStyleBuild build = project.scheduleBuild2(0).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例9: testAbsolutePath
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void testAbsolutePath() throws Exception {
String absoluteFilePath = "/tmp/bar.txt";
glob = absoluteFilePath;
underTest = new GoogleCloudStorageUploader(CREDENTIALS_ID,
ImmutableList.<AbstractUpload>of(setOptionalParams(
new ClassicUpload(bucket, new MockUploadModule(executor),
glob, null /* legacy arg */, null /* legacy arg */))));
project.getBuildersList().add(new Shell("echo foo > " +
absoluteFilePath));
project.getPublishersList().add(underTest);
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.passThruWhen(Storage.Buckets.Insert.class);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
FreeStyleBuild build = project.scheduleBuild2(0).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例10: testAbsoluteGlob
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void testAbsoluteGlob() throws Exception {
String absoluteFilePath1 = "/tmp/bar.1.txt";
String absoluteFilePath2 = "/tmp/bar.2.txt";
glob = "/tmp/bar.*.txt";
underTest = new GoogleCloudStorageUploader(CREDENTIALS_ID,
ImmutableList.<AbstractUpload>of(setOptionalParams(
new ClassicUpload(bucket, new MockUploadModule(executor),
glob, null /* legacy arg */, null /* legacy arg */))));
project.getBuildersList().add(new Shell("echo foo > " +
absoluteFilePath1));
project.getBuildersList().add(new Shell("echo foo > " +
absoluteFilePath2));
project.getPublishersList().add(underTest);
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.passThruWhen(Storage.Buckets.Insert.class);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
FreeStyleBuild build = project.scheduleBuild2(0).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例11: testFileWithVar
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void testFileWithVar() throws Exception {
glob = "bar.$BUILD_NUMBER.txt";
underTest = new GoogleCloudStorageUploader(CREDENTIALS_ID,
ImmutableList.<AbstractUpload>of(setOptionalParams(
new ClassicUpload(bucket, new MockUploadModule(executor),
glob, null /* legacy arg */, null /* legacy arg */))));
project.getBuildersList().add(
new Shell("echo foo > bar.$BUILD_NUMBER.txt"));
project.getPublishersList().add(underTest);
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.passThruWhen(Storage.Buckets.Insert.class);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
FreeStyleBuild build = project.scheduleBuild2(0).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例12: testFileWithDir
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void testFileWithDir() throws Exception {
glob = "blah/bar.txt";
underTest = new GoogleCloudStorageUploader(CREDENTIALS_ID,
ImmutableList.<AbstractUpload>of(setOptionalParams(
new ClassicUpload(bucket, new MockUploadModule(executor),
glob, null /* legacy arg */, null /* legacy arg */))));
project.getBuildersList().add(
new Shell("mkdir blah; echo foo > blah/bar.txt"));
project.getPublishersList().add(underTest);
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.passThruWhen(Storage.Buckets.Insert.class);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
FreeStyleBuild build = project.scheduleBuild2(0).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例13: testFileWithRecursiveGlob
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void testFileWithRecursiveGlob() throws Exception {
glob = "**/*.txt";
underTest = new GoogleCloudStorageUploader(CREDENTIALS_ID,
ImmutableList.<AbstractUpload>of(setOptionalParams(
new ClassicUpload(bucket, new MockUploadModule(executor),
glob, null /* legacy arg */, null /* legacy arg */))));
project.getBuildersList().add(
new Shell("mkdir blah; echo foo > blah/bar.txt"));
project.getPublishersList().add(underTest);
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.passThruWhen(Storage.Buckets.Insert.class);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
FreeStyleBuild build = project.scheduleBuild2(0).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例14: testMultiFileGlob
import hudson.tasks.Shell; //导入依赖的package包/类
@Test
public void testMultiFileGlob() throws Exception {
glob = "*.txt";
underTest = new GoogleCloudStorageUploader(CREDENTIALS_ID,
ImmutableList.<AbstractUpload>of(setOptionalParams(
new ClassicUpload(bucket, new MockUploadModule(executor),
glob, null /* legacy arg */, null /* legacy arg */))));
project.getBuildersList().add(
new Shell("echo foo > foo.txt; echo bar > bar.txt"));
project.getPublishersList().add(underTest);
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.passThruWhen(Storage.Buckets.Insert.class);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
FreeStyleBuild build = project.scheduleBuild2(0).get();
assertEquals(Result.SUCCESS, build.getResult());
}
示例15: givenSearchWhenJobsWithBuildsAreExecutedThenTheyShouldBeSearchable
import hudson.tasks.Shell; //导入依赖的package包/类
public static void givenSearchWhenJobsWithBuildsAreExecutedThenTheyShouldBeSearchable(
JenkinsSearchBackend jenkinsSearchBackend, JenkinsRule rule) throws IOException, ExecutionException,
InterruptedException, SAXException, URISyntaxException, TimeoutException {
assertEquals(0, jenkinsSearchBackend.search("echo").suggestions.size());
FreeStyleProject project1 = rule.createFreeStyleProject("project1");
project1.getBuildersList().add(new Shell("echo $BUILD_TAG\n"));
// Building
project1.scheduleBuild2(0).get();
project1.scheduleBuild2(0).get();
project1.scheduleBuild2(0).get();
rule.createFreeStyleProject("project2");
FreeStyleProject project3 = rule.createFreeStyleProject("project3");
project3.getBuildersList().add(new Shell("cat $BUILD_TAG\n"));
assertEquals(3, jenkinsSearchBackend.search("echo").suggestions.size());
rebuildDatabase(jenkinsSearchBackend, rule);
assertEquals(3, jenkinsSearchBackend.search("echo").suggestions.size());
}