当前位置: 首页>>代码示例>>Java>>正文


Java Shell类代码示例

本文整理汇总了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());
}
 
开发者ID:jenkinsci,项目名称:marathon-plugin,代码行数:22,代码来源:MarathonRecorderTest.java

示例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);
}
 
开发者ID:damienbiggs,项目名称:parameter-pool-plugin,代码行数:20,代码来源:ParameterPoolTest.java

示例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());
}
 
开发者ID:SumoLogic,项目名称:sumologic-jenkins-plugin,代码行数:24,代码来源:SumoBuildNotifierTest.java

示例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;
}
 
开发者ID:KostyaSha,项目名称:yet-another-docker-plugin,代码行数:27,代码来源:FreestyleTest.java

示例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();
}
 
开发者ID:KostyaSha,项目名称:yet-another-docker-plugin,代码行数:23,代码来源:DockerSimpleBuildWrapperTest.java

示例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());
}
 
开发者ID:jenkinsci,项目名称:google-storage-plugin,代码行数:23,代码来源:GoogleCloudStorageUploaderTest.java

示例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());
}
 
开发者ID:jenkinsci,项目名称:google-storage-plugin,代码行数:20,代码来源:GoogleCloudStorageUploaderTest.java

示例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());
}
 
开发者ID:jenkinsci,项目名称:google-storage-plugin,代码行数:20,代码来源:GoogleCloudStorageUploaderTest.java

示例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());
}
 
开发者ID:jenkinsci,项目名称:google-storage-plugin,代码行数:22,代码来源:GoogleCloudStorageUploaderTest.java

示例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());
}
 
开发者ID:jenkinsci,项目名称:google-storage-plugin,代码行数:26,代码来源:GoogleCloudStorageUploaderTest.java

示例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());
}
 
开发者ID:jenkinsci,项目名称:google-storage-plugin,代码行数:21,代码来源:GoogleCloudStorageUploaderTest.java

示例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());
}
 
开发者ID:jenkinsci,项目名称:google-storage-plugin,代码行数:21,代码来源:GoogleCloudStorageUploaderTest.java

示例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());
}
 
开发者ID:jenkinsci,项目名称:google-storage-plugin,代码行数:21,代码来源:GoogleCloudStorageUploaderTest.java

示例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());
}
 
开发者ID:jenkinsci,项目名称:google-storage-plugin,代码行数:22,代码来源:GoogleCloudStorageUploaderTest.java

示例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());
}
 
开发者ID:jenkinsci,项目名称:lucene-search-plugin,代码行数:20,代码来源:CommonTestCases.java


注:本文中的hudson.tasks.Shell类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。