Search in sources :

Example 36 with FreeStyleBuild

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

the class PipelineApiTest method getFreeStyleJobTest.

@Test
public void getFreeStyleJobTest() throws Exception {
    Project p1 = j.createFreeStyleProject("pipeline1");
    Project p2 = j.createFreeStyleProject("pipeline2");
    p1.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    FreeStyleBuild b = (FreeStyleBuild) p1.scheduleBuild2(0).get();
    j.assertBuildStatusSuccess(b);
    List<Map> resp = get("/organizations/jenkins/pipelines/", List.class);
    Project[] projects = { p1, p2 };
    assertEquals(projects.length, resp.size());
    for (int i = 0; i < projects.length; i++) {
        Map p = resp.get(i);
        validatePipeline(projects[i], p);
    }
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) Shell(hudson.tasks.Shell) FreeStyleBuild(hudson.model.FreeStyleBuild) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 37 with FreeStyleBuild

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

the class PipelineApiTest method findPipelineRunsForAPipelineTest.

@Test
public void findPipelineRunsForAPipelineTest() throws Exception {
    FreeStyleProject p1 = j.createFreeStyleProject("pipeline1");
    FreeStyleProject p2 = j.createFreeStyleProject("pipeline2");
    p1.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    p2.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    Stack<FreeStyleBuild> builds = new Stack<FreeStyleBuild>();
    FreeStyleBuild b11 = p1.scheduleBuild2(0).get();
    FreeStyleBuild b12 = p1.scheduleBuild2(0).get();
    builds.push(b11);
    builds.push(b12);
    j.assertBuildStatusSuccess(b11);
    j.assertBuildStatusSuccess(b12);
    List<Map> resp = get("/search?q=type:run;organization:jenkins;pipeline:pipeline1", List.class);
    assertEquals(builds.size(), resp.size());
    for (int i = 0; i < builds.size(); i++) {
        Map p = resp.get(i);
        FreeStyleBuild b = builds.pop();
        validateRun(b, 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)

Example 38 with FreeStyleBuild

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

the class PipelineApiTest method getPipelineRunLatestTest.

@Test
public void getPipelineRunLatestTest() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject("pipeline5");
    p.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    FreeStyleBuild b = p.scheduleBuild2(0).get();
    j.assertBuildStatusSuccess(b);
    List<Map> resp = get("/search?q=type:run;organization:jenkins;pipeline:pipeline5;latestOnly:true", List.class);
    Run[] run = { b };
    assertEquals(run.length, resp.size());
    for (int i = 0; i < run.length; i++) {
        Map lr = resp.get(i);
        validateRun(run[i], lr);
    }
}
Also used : Shell(hudson.tasks.Shell) Run(hudson.model.Run) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 39 with FreeStyleBuild

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

the class PipelineApiTest method getPipelineWithLastSuccessfulRun.

@Test
public void getPipelineWithLastSuccessfulRun() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject("pipeline4");
    p.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    FreeStyleBuild b = p.scheduleBuild2(0).get();
    j.assertBuildStatusSuccess(b);
    Map resp = get("/organizations/jenkins/pipelines/pipeline4/");
    validatePipeline(p, resp);
}
Also used : Shell(hudson.tasks.Shell) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 40 with FreeStyleBuild

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

the class PipelineApiTest method getPipelinesTest.

@Test
public void getPipelinesTest() throws Exception {
    Project p2 = j.createFreeStyleProject("pipeline2");
    Project p1 = j.createFreeStyleProject("pipeline1");
    List<Map> responses = get("/search/?q=type:pipeline", List.class);
    assertEquals(2, responses.size());
    validatePipeline(p1, responses.get(0));
    validatePipeline(p2, responses.get(1));
    p1.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    FreeStyleBuild b = (FreeStyleBuild) p1.scheduleBuild2(0).get();
    j.assertBuildStatusSuccess(b);
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) Shell(hudson.tasks.Shell) FreeStyleBuild(hudson.model.FreeStyleBuild) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

FreeStyleBuild (hudson.model.FreeStyleBuild)45 FreeStyleProject (hudson.model.FreeStyleProject)45 Test (org.junit.Test)28 Shell (hudson.tasks.Shell)15 JobPropertyImpl (hudson.plugins.promoted_builds.JobPropertyImpl)14 PromotionProcess (hudson.plugins.promoted_builds.PromotionProcess)13 Map (java.util.Map)13 ImmutableMap (com.google.common.collect.ImmutableMap)12 PromotedBuildAction (hudson.plugins.promoted_builds.PromotedBuildAction)8 Promotion (hudson.plugins.promoted_builds.Promotion)7 StringParameterDefinition (hudson.model.StringParameterDefinition)6 ManualCondition (hudson.plugins.promoted_builds.conditions.ManualCondition)6 ManualApproval (hudson.plugins.promoted_builds.conditions.ManualCondition.ManualApproval)6 Descriptor (hudson.model.Descriptor)5 ParameterValue (hudson.model.ParameterValue)5 MockFolder (org.jvnet.hudson.test.MockFolder)5 StringParameterValue (hudson.model.StringParameterValue)4 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)3 Project (hudson.model.Project)3 DescriptorImpl (hudson.plugins.promoted_builds.JobPropertyImpl.DescriptorImpl)3