Search in sources :

Example 76 with FreeStyleProject

use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method getPipelineRunWithTestResult.

@Test
public void getPipelineRunWithTestResult() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject("pipeline4");
    p.getBuildersList().add(new Shell("echo '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<testsuite xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd\" name=\"io.jenkins.blueocean.jsextensions.JenkinsJSExtensionsTest\" time=\"35.7\" tests=\"1\" errors=\"0\" skipped=\"0\" failures=\"0\">\n" + "  <properties>\n" + "  </properties>\n" + "  <testcase name=\"test\" classname=\"io.jenkins.blueocean.jsextensions.JenkinsJSExtensionsTest\" time=\"34.09\"/>\n" + "</testsuite>' > test-result.xml"));
    p.getPublishersList().add(new JUnitResultArchiver("*.xml"));
    FreeStyleBuild b = p.scheduleBuild2(0).get();
    TestResultAction resultAction = b.getAction(TestResultAction.class);
    assertEquals("io.jenkins.blueocean.jsextensions.JenkinsJSExtensionsTest", resultAction.getResult().getSuites().iterator().next().getName());
    j.assertBuildStatusSuccess(b);
    Map resp = get("/organizations/jenkins/pipelines/pipeline4/runs/" + b.getId());
    //discover TestResultAction super classes
    get("/classes/hudson.tasks.junit.TestResultAction/");
    // get junit rest report
    get("/organizations/jenkins/pipelines/pipeline4/runs/" + b.getId() + "/testReport/result/");
}
Also used : Shell(hudson.tasks.Shell) JUnitResultArchiver(hudson.tasks.junit.JUnitResultArchiver) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) TestResultAction(hudson.tasks.junit.TestResultAction) Test(org.junit.Test)

Example 77 with FreeStyleProject

use of hudson.model.FreeStyleProject in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method findPipelineRunsForAllPipelineTest.

@Test
public void findPipelineRunsForAllPipelineTest() throws IOException, ExecutionException, InterruptedException {
    FreeStyleProject p1 = j.createFreeStyleProject("pipeline11");
    FreeStyleProject p2 = j.createFreeStyleProject("pipeline22");
    p1.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    p2.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    Stack<FreeStyleBuild> p1builds = new Stack<FreeStyleBuild>();
    p1builds.push(p1.scheduleBuild2(0).get());
    p1builds.push(p1.scheduleBuild2(0).get());
    Stack<FreeStyleBuild> p2builds = new Stack<FreeStyleBuild>();
    p2builds.push(p2.scheduleBuild2(0).get());
    p2builds.push(p2.scheduleBuild2(0).get());
    Map<String, Stack<FreeStyleBuild>> buildMap = ImmutableMap.of(p1.getName(), p1builds, p2.getName(), p2builds);
    List<Map> resp = get("/search?q=type:run;organization:jenkins", List.class);
    assertEquals(4, resp.size());
    for (int i = 0; i < 4; i++) {
        Map p = resp.get(i);
        String pipeline = (String) p.get("pipeline");
        assertNotNull(pipeline);
        validateRun(buildMap.get(pipeline).pop(), p);
    }
}
Also used : Shell(hudson.tasks.Shell) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Stack(java.util.Stack) Test(org.junit.Test)

Aggregations

FreeStyleProject (hudson.model.FreeStyleProject)77 Test (org.junit.Test)49 FreeStyleBuild (hudson.model.FreeStyleBuild)39 Shell (hudson.tasks.Shell)17 Map (java.util.Map)16 JobPropertyImpl (hudson.plugins.promoted_builds.JobPropertyImpl)14 ImmutableMap (com.google.common.collect.ImmutableMap)13 PromotionProcess (hudson.plugins.promoted_builds.PromotionProcess)13 ArrayList (java.util.ArrayList)11 StringParameterDefinition (hudson.model.StringParameterDefinition)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 PromotedBuildAction (hudson.plugins.promoted_builds.PromotedBuildAction)8 FreeStyleProjectMock (hudson.model.FreeStyleProjectMock)7 Promotion (hudson.plugins.promoted_builds.Promotion)7 MockFolder (org.jvnet.hudson.test.MockFolder)7 ManualCondition (hudson.plugins.promoted_builds.conditions.ManualCondition)6 ManualApproval (hudson.plugins.promoted_builds.conditions.ManualCondition.ManualApproval)6 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)5 Descriptor (hudson.model.Descriptor)5 Hudson (hudson.model.Hudson)5