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


Java CaptureEnvironmentBuilder类代码示例

本文整理汇总了Java中org.jvnet.hudson.test.CaptureEnvironmentBuilder的典型用法代码示例。如果您正苦于以下问题:Java CaptureEnvironmentBuilder类的具体用法?Java CaptureEnvironmentBuilder怎么用?Java CaptureEnvironmentBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CaptureEnvironmentBuilder类属于org.jvnet.hudson.test包,在下文中一共展示了CaptureEnvironmentBuilder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupProject

import org.jvnet.hudson.test.CaptureEnvironmentBuilder; //导入依赖的package包/类
protected FreeStyleProject setupProject(List<BranchSpec> branches, boolean authorOrCommitter,
    String relativeTargetDir, String excludedRegions,
    String excludedUsers, String localBranch, boolean fastRemotePoll,
    String includedRegions, List<SparseCheckoutPath> sparseCheckoutPaths) throws Exception {
  FreeStyleProject project = createFreeStyleProject();
  GitSCM scm = new GitSCM(
      createRemoteRepositories(),
      branches,
      false, Collections.<SubmoduleConfig>emptyList(),
      null, null,
      Collections.<GitSCMExtension>emptyList());
  scm.getExtensions().add(new DisableRemotePoll()); // don't work on a file:// repository
  if (relativeTargetDir!=null)
    scm.getExtensions().add(new RelativeTargetDirectory(relativeTargetDir));
  if (excludedUsers!=null)
    scm.getExtensions().add(new UserExclusion(excludedUsers));
  if (excludedRegions!=null || includedRegions!=null)
    scm.getExtensions().add(new PathRestriction(includedRegions,excludedRegions));

  scm.getExtensions().add(new SparseCheckoutPaths(sparseCheckoutPaths));

  project.setScm(scm);
  project.getBuildersList().add(new CaptureEnvironmentBuilder());
  return project;
}
 
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:26,代码来源:AbstractGitTestCase.java

示例2: testEnvData

import org.jvnet.hudson.test.CaptureEnvironmentBuilder; //导入依赖的package包/类
/**
 * Test that info about selected builds is added into the environment for later build steps.
 */
@Test
public void testEnvData() throws Exception {
    // Also test conversion of job name to env var name, only keeping letters:
    FreeStyleProject other = createArtifactProject("My (Test) Job"),
             p = createProject(other.getName(), null, "", "", false, false, false, true);
    CaptureEnvironmentBuilder envStep = new CaptureEnvironmentBuilder();
    p.getBuildersList().add(envStep);
    // Bump up the build number a bit:
    for (int i = 0; i < 3; i++) other.assignBuildNumber();
    rule.assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause()).get());
    FreeStyleBuild b = p.scheduleBuild2(0, new UserCause()).get();
    rule.assertBuildStatusSuccess(b);
    assertEquals("4", envStep.getEnvVars().get("COPYARTIFACT_BUILD_NUMBER_MY_TEST_JOB"));
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:18,代码来源:CopyArtifactTest.java

示例3: testEnvDataInMavenProject

import org.jvnet.hudson.test.CaptureEnvironmentBuilder; //导入依赖的package包/类
@Issue("JENKINS-16028")
@Test
public void testEnvDataInMavenProject() throws Exception {
    FreeStyleProject upstream = rule.createFreeStyleProject("upstream");
    upstream.getBuildersList().add(new FileWriteBuilder("artifact.txt", "foobar"));
    upstream.getPublishersList().add(new ArtifactArchiver("**/*", "", false, false));
    FreeStyleBuild upstreamBuild = upstream.scheduleBuild2(0).get();
    rule.assertBuildStatusSuccess(upstreamBuild);
    
    MavenModuleSet downstream = setupMavenJob();
    downstream.getPrebuilders().add(CopyArtifactUtil.createRunSelector(
            "upstream",
            "",
            new BuildNumberRunSelector(Integer.toString(upstreamBuild.getNumber())),
            "**/*",
            "",
            "",
            false,
            false,
            false
    ));
    CaptureEnvironmentBuilder envStep = new CaptureEnvironmentBuilder();
    downstream.getPrebuilders().add(envStep);
    
    MavenModuleSetBuild downstreamBuild = downstream.scheduleBuild2(0).get();
    rule.assertBuildStatusSuccess(downstreamBuild);
    assertFile(true, "artifact.txt", downstreamBuild);
    assertEquals(
            Integer.toString(upstreamBuild.getNumber()),
            envStep.getEnvVars().get("COPYARTIFACT_BUILD_NUMBER_UPSTREAM")
    );
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:33,代码来源:CopyArtifactTest.java

示例4: testEnvDataWrapped

import org.jvnet.hudson.test.CaptureEnvironmentBuilder; //导入依赖的package包/类
@Issue("JENKINS-18762")
@Test
public void testEnvDataWrapped() throws Exception {
    FreeStyleProject upstream = rule.createFreeStyleProject("upstream");
    upstream.getBuildersList().add(new FileWriteBuilder("artifact.txt", "foobar"));
    upstream.getPublishersList().add(new ArtifactArchiver("**/*", "", false, false));
    FreeStyleBuild upstreamBuild = upstream.scheduleBuild2(0).get();
    rule.assertBuildStatusSuccess(upstreamBuild);
    
    FreeStyleProject downstream = rule.createFreeStyleProject();
    downstream.getBuildersList().add(new WrapperBuilder(CopyArtifactUtil.createRunSelector(
            "upstream",
            "",
            new BuildNumberRunSelector(Integer.toString(upstreamBuild.getNumber())),
            "**/*",
            "",
            "",
            false,
            false,
            false
    )));
    CaptureEnvironmentBuilder envStep = new CaptureEnvironmentBuilder();
    downstream.getBuildersList().add(envStep);
    
    FreeStyleBuild downstreamBuild = downstream.scheduleBuild2(0).get();
    rule.assertBuildStatusSuccess(downstreamBuild);
    assertFile(true, "artifact.txt", downstreamBuild);
    assertEquals(
            Integer.toString(upstreamBuild.getNumber()),
            envStep.getEnvVars().get("COPYARTIFACT_BUILD_NUMBER_UPSTREAM")
    );
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:33,代码来源:CopyArtifactTest.java

示例5: testFilterByMetaParameters

import org.jvnet.hudson.test.CaptureEnvironmentBuilder; //导入依赖的package包/类
@Test
public void testFilterByMetaParameters() throws Exception {
    FreeStyleProject other = createArtifactProject("Foo job");
    other.addProperty(new ParametersDefinitionProperty(new BooleanParameterDefinition("BAR", false, "")));
    rule.assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause(), new ParametersAction(new BooleanParameterValue("BAR", false))).get());
    rule.assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause(), new ParametersAction(new BooleanParameterValue("BAR", true))).get());
    rule.assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause(), new ParametersAction(new BooleanParameterValue("BAR", false))).get());
    FreeStyleProject p = createProject(other.getName(), "$VAR=true", "*.txt", "", true, false, false, true);
    p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("VAR", "")));
    CaptureEnvironmentBuilder envStep = new CaptureEnvironmentBuilder();
    p.getBuildersList().add(envStep);
    FreeStyleBuild b = p.scheduleBuild2(0, new UserCause(), new ParametersAction(new StringParameterValue("VAR", "BAR"))).get();
    rule.assertBuildStatusSuccess(b);
    assertEquals("2", envStep.getEnvVars().get("COPYARTIFACT_BUILD_NUMBER_FOO_JOB"));
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:16,代码来源:CopyArtifactTest.java

示例6: getEnvVars

import org.jvnet.hudson.test.CaptureEnvironmentBuilder; //导入依赖的package包/类
protected EnvVars getEnvVars(FreeStyleProject project) {
  for (hudson.tasks.Builder b : project.getBuilders()) {
    if (b instanceof CaptureEnvironmentBuilder) {
      return ((CaptureEnvironmentBuilder)b).getEnvVars();
    }
  }
  return new EnvVars();
}
 
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:9,代码来源:AbstractGitTestCase.java

示例7: testFilterByParameters

import org.jvnet.hudson.test.CaptureEnvironmentBuilder; //导入依赖的package包/类
/**
 * Test filtering on parameters, ie. last stable build with parameter FOO=bar.
 */
@Test
public void testFilterByParameters() throws Exception {
    FreeStyleProject other = createArtifactProject("Foo job");
    other.addProperty(new ParametersDefinitionProperty(
            new StringParameterDefinition("FOO", ""),
            new BooleanParameterDefinition("BAR", false, ""),
            new ChoiceParameterDefinition("BAZ", new String[] { "foo", "bar", "baz" }, "")));
    // #1: FOO=foo BAR=false BAZ=baz
    rule.assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause(), new ParametersAction(
            new StringParameterValue("FOO", "foo"),
            new BooleanParameterValue("BAR", false),
            new StringParameterValue("BAZ", "baz"))).get());
    // #2: FOO=bar BAR=true BAZ=foo
    rule.assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause(), new ParametersAction(
            new StringParameterValue("FOO", "bar"),
            new BooleanParameterValue("BAR", true),
            new StringParameterValue("BAZ", "foo"))).get());
    // #3: FOO=foo BAR=true BAZ=bar
    rule.assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause(), new ParametersAction(
            new StringParameterValue("FOO", "foo"),
            new BooleanParameterValue("BAR", true),
            new StringParameterValue("BAZ", "bar"))).get());

    FreeStyleProject p = createProject(other.getName(), "FOO=bar", "*.txt", "", true, false, false, true);
    CaptureEnvironmentBuilder envStep = new CaptureEnvironmentBuilder();
    p.getBuildersList().add(envStep);
    FreeStyleBuild b = p.scheduleBuild2(0, new UserCause()).get();
    rule.assertBuildStatusSuccess(b);
    assertEquals("2", envStep.getEnvVars().get("COPYARTIFACT_BUILD_NUMBER_FOO_JOB"));

    p = createProject(other.getName(), "BAR=false", "*.txt", "", true, false, false, true);
    p.getBuildersList().add(envStep);
    b = p.scheduleBuild2(0, new UserCause()).get();
    rule.assertBuildStatusSuccess(b);
    assertEquals("1", envStep.getEnvVars().get("COPYARTIFACT_BUILD_NUMBER_FOO_JOB"));

    p = createProject(other.getName(), "BAZ=foo,BAR=true", "*.txt", "", true, false, false, true);
    p.getBuildersList().add(envStep);
    b = p.scheduleBuild2(0, new UserCause()).get();
    rule.assertBuildStatusSuccess(b);
    assertEquals("2", envStep.getEnvVars().get("COPYARTIFACT_BUILD_NUMBER_FOO_JOB"));

    p = createProject(other.getName(), "FOO=foo,BAR=false,BAZ=baz", "*.txt", "", true, false, false, true);
    p.getBuildersList().add(envStep);
    b = p.scheduleBuild2(0, new UserCause()).get();
    rule.assertBuildStatusSuccess(b);
    assertEquals("1", envStep.getEnvVars().get("COPYARTIFACT_BUILD_NUMBER_FOO_JOB"));

    p = createProject(other.getName(), "BAZ=bar,FOO=bogus", "*.txt", "", true, false, false, true);
    b = p.scheduleBuild2(0, new UserCause()).get();
    rule.assertBuildStatus(Result.FAILURE, b);

    // Test matching other build variables besides parameters
    p = createProject(other.getName(), "BUILD_NUMBER=2", "*.txt", "", true, false, false, true);
    p.getBuildersList().add(envStep);
    b = p.scheduleBuild2(0, new UserCause()).get();
    rule.assertBuildStatusSuccess(b);
    assertEquals("2", envStep.getEnvVars().get("COPYARTIFACT_BUILD_NUMBER_FOO_JOB"));
    
    // Test coverage for EnvAction
    boolean ok = false;
    for (Action a : b.getActions()) {
        if ("hudson.plugins.runselector.RunSelector$EnvAction".equals(a.getClass().getName())) {
            assertNull(a.getIconFileName());
            assertNull(a.getDisplayName());
            assertNull(a.getUrlName());
            ok = true;
        }
    }
    assertTrue(ok);
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:75,代码来源:CopyArtifactTest.java

示例8: testParameter

import org.jvnet.hudson.test.CaptureEnvironmentBuilder; //导入依赖的package包/类
/**
 * Verify RunSelectorParameter works via HTML form, http POST and CLI.
 */
@Test
public void testParameter() throws Exception {
    FreeStyleProject job = rule.createFreeStyleProject();
    job.addProperty(new ParametersDefinitionProperty(
            new RunSelectorParameter("SELECTOR", new StatusRunSelector(StatusRunSelector.BuildStatus.SUCCESSFUL), "foo")));
    CaptureEnvironmentBuilder ceb = new CaptureEnvironmentBuilder();
    job.getBuildersList().add(ceb);

    // Run via UI (HTML form)
    WebClient wc = rule.createWebClient();
    WebClientOptions wco = wc.getOptions();
    // Jenkins sends 405 response for GET of build page.. deal with that:
    wco.setThrowExceptionOnFailingStatusCode(false);
    wco.setPrintContentOnFailingStatusCode(false);
    HtmlForm form = wc.getPage(job, "build").getFormByName("parameters");
    form.getSelectByName("").getOptionByText("Specified by build number").setSelected(true);
    wc.waitForBackgroundJavaScript(10000);
    form.getInputByName("_.buildNumber").setValueAttribute("6");
    rule.submit(form);
    Queue.Item q = rule.jenkins.getQueue().getItem(job);
    if (q != null) q.getFuture().get();
    while (job.getLastBuild().isBuilding()) Thread.sleep(100);
    assertEquals("<BuildNumberRunSelector><buildNumber>6</buildNumber></BuildNumberRunSelector>",
            ceb.getEnvVars().get("SELECTOR").replaceAll("\\s+", ""));
    job.getBuildersList().replace(ceb = new CaptureEnvironmentBuilder());

    // Run via HTTP POST (buildWithParameters)
    WebRequest post = new WebRequest(
            new URL(rule.getURL(), job.getUrl() + "/buildWithParameters"), HttpMethod.POST);
    wc.addCrumb(post);
    String xml = "<StatusRunSelector><buildStatus>STABLE</buildStatus></StatusRunSelector>";
    post.setRequestParameters(Arrays.asList(new NameValuePair("SELECTOR", xml),
            post.getRequestParameters().get(0)));
    wc.getPage(post);
    q = rule.jenkins.getQueue().getItem(job);
    if (q != null) q.getFuture().get();
    while (job.getLastBuild().isBuilding()) Thread.sleep(100);
    assertEquals(xml, ceb.getEnvVars().get("SELECTOR"));
    job.getBuildersList().replace(ceb = new CaptureEnvironmentBuilder());

    // Run via CLI
    CLI cli = new CLI(rule.getURL());
    assertEquals(0, cli.execute(
            "build", job.getFullName(), "-p", "SELECTOR=<StatusRunSelector/>"));
    q = rule.jenkins.getQueue().getItem(job);
    if (q != null) q.getFuture().get();
    while (job.getLastBuild().isBuilding()) Thread.sleep(100);
    assertEquals("<StatusRunSelector/>", ceb.getEnvVars().get("SELECTOR"));
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:53,代码来源:RunSelectorParameterTest.java


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