Search in sources :

Example 11 with FreeStyleProject

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

the class PipelineApiTest method getPipelineRunsTest.

@Test
public void getPipelineRunsTest() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject("pipeline6");
    p.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    FreeStyleBuild b = p.scheduleBuild2(0).get();
    j.assertBuildStatusSuccess(b);
    List<Map> resp = get("/organizations/jenkins/pipelines/pipeline6/runs", List.class);
    assertEquals(1, resp.size());
    Map lr = resp.get(0);
    validateRun(b, lr);
}
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 12 with FreeStyleProject

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

the class PipelineApiTest method testNewPipelineQueueItem.

@Test
public void testNewPipelineQueueItem() throws Exception {
    FreeStyleProject p1 = j.createFreeStyleProject("pipeline1");
    FreeStyleProject p2 = j.createFreeStyleProject("pipeline2");
    FreeStyleProject p3 = j.createFreeStyleProject("pipeline3");
    p1.getBuildersList().add(new Shell("echo hello!\nsleep 300"));
    p2.getBuildersList().add(new Shell("echo hello!\nsleep 300"));
    p3.getBuildersList().add(new Shell("echo hello!\nsleep 300"));
    p1.scheduleBuild2(0).waitForStart();
    p2.scheduleBuild2(0).waitForStart();
    Map r = request().post("/organizations/jenkins/pipelines/pipeline3/runs/").build(Map.class);
    assertNotNull(p3.getQueueItem());
    String id = Long.toString(p3.getQueueItem().getId());
    assertEquals(id, r.get("id"));
    delete("/organizations/jenkins/pipelines/pipeline3/queue/" + id + "/");
    Queue.Item item = j.jenkins.getQueue().getItem(Long.parseLong(id));
    assertTrue(item instanceof Queue.LeftItem);
    assertTrue(((Queue.LeftItem) item).isCancelled());
}
Also used : Shell(hudson.tasks.Shell) FreeStyleProject(hudson.model.FreeStyleProject) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Queue(hudson.model.Queue) Test(org.junit.Test)

Example 13 with FreeStyleProject

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

the class PipelineApiTest method testArtifactsRunApi.

@Test
public void testArtifactsRunApi() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject("pipeline1");
    p.getBuildersList().add(new TestBuilder() {

        @Override
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            FilePath ws = build.getWorkspace();
            if (ws == null) {
                return false;
            }
            FilePath dir = ws.child("dir");
            dir.mkdirs();
            dir.child("fizz").write("contents", null);
            dir.child("lodge").symlinkTo("fizz", listener);
            return true;
        }
    });
    ArtifactArchiver aa = new ArtifactArchiver("dir/fizz");
    aa.setAllowEmptyArchive(true);
    p.getPublishersList().add(aa);
    FreeStyleBuild b = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
    List artifacts = get("/organizations/jenkins/pipelines/pipeline1/runs/" + b.getId() + "/artifacts", List.class);
    assertEquals(1, artifacts.size());
    assertEquals("fizz", ((Map) artifacts.get(0)).get("name"));
}
Also used : FilePath(hudson.FilePath) BuildListener(hudson.model.BuildListener) ArtifactArchiver(hudson.tasks.ArtifactArchiver) Launcher(hudson.Launcher) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) IOException(java.io.IOException) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) TestBuilder(org.jvnet.hudson.test.TestBuilder) Test(org.junit.Test)

Example 14 with FreeStyleProject

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

the class PipelineApiTest method getPipelineRunTest.

@Test
public void getPipelineRunTest() 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/runs/" + b.getId());
    validateRun(b, 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 15 with FreeStyleProject

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

the class ArtifactContainerImplTest method testArtifact.

//@Test TODO needs viveks input
public void testArtifact() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject(JOB_NAME);
    p.getBuildersList().add(new Shell("mkdir -p test/me/out; touch test/me/out/{{a..z},{A..Z},{0..99}}.txt"));
    p.getPublishersList().add(new ArtifactArchiver("**/*"));
    Run r = p.scheduleBuild2(0).waitForStart();
    r = j.waitForCompletion(r);
    Map artifact = request().get("/organizations/jenkins/pipelines/" + JOB_NAME + "/runs/" + r.getId() + "/artifacts/test%252Fme%252Fout%252F0.txt").build(Map.class);
    Assert.assertEquals(100, artifact.size());
}
Also used : Shell(hudson.tasks.Shell) ArtifactArchiver(hudson.tasks.ArtifactArchiver) Run(hudson.model.Run) FreeStyleProject(hudson.model.FreeStyleProject) Map(java.util.Map)

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