Search in sources :

Example 71 with FreeStyleProject

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

the class PipelineApiTest method findPipelinesTest.

@Test
public void findPipelinesTest() throws IOException {
    FreeStyleProject p1 = j.createFreeStyleProject("pipeline2");
    FreeStyleProject p2 = j.createFreeStyleProject("pipeline3");
    List<Map> resp = get("/search?q=type:pipeline;organization:jenkins", 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) FreeStyleProject(hudson.model.FreeStyleProject) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 72 with FreeStyleProject

use of hudson.model.FreeStyleProject 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 73 with FreeStyleProject

use of hudson.model.FreeStyleProject 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 74 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)

Example 75 with FreeStyleProject

use of hudson.model.FreeStyleProject in project hudson-2.x by hudson.

the class FunctionsTest method testGetTemplateWithoutTemplates.

@Test
public void testGetTemplateWithoutTemplates() {
    List<FreeStyleProject> items = new ArrayList<FreeStyleProject>();
    FreeStyleProject project = Functions.getItemByName(items, TEMPLATE_NAME);
    assertNull(project);
}
Also used : ArrayList(java.util.ArrayList) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

FreeStyleProject (hudson.model.FreeStyleProject)88 Test (org.junit.Test)61 FreeStyleBuild (hudson.model.FreeStyleBuild)42 Shell (hudson.tasks.Shell)21 Map (java.util.Map)20 ImmutableMap (com.google.common.collect.ImmutableMap)17 JobPropertyImpl (hudson.plugins.promoted_builds.JobPropertyImpl)14 PromotionProcess (hudson.plugins.promoted_builds.PromotionProcess)13 ArrayList (java.util.ArrayList)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)11 StringParameterDefinition (hudson.model.StringParameterDefinition)10 MockFolder (org.jvnet.hudson.test.MockFolder)10 List (java.util.List)9 PromotedBuildAction (hudson.plugins.promoted_builds.PromotedBuildAction)8 ImmutableList (com.google.common.collect.ImmutableList)7 FreeStyleProjectMock (hudson.model.FreeStyleProjectMock)7 Promotion (hudson.plugins.promoted_builds.Promotion)7 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)6 Run (hudson.model.Run)6 ManualCondition (hudson.plugins.promoted_builds.conditions.ManualCondition)6