Search in sources :

Example 16 with Shell

use of hudson.tasks.Shell in project hudson-2.x by hudson.

the class CopyOnWriteListEqualsHashCodeTest method setUp.

@Before
public void setUp() {
    data1 = new ArrayList<Builder>();
    data1.add(new Shell("echo 'test'"));
    data1.add(new Shell("echo 'test1'"));
    data1.add(new Shell("echo 'test2'"));
    data2 = new ArrayList<Builder>();
    data2.add(new Shell("echo 'test1'"));
    data2.add(new Shell("echo 'test'"));
}
Also used : Shell(hudson.tasks.Shell) Builder(hudson.tasks.Builder) Before(org.junit.Before)

Example 17 with Shell

use of hudson.tasks.Shell in project promoted-builds-plugin by jenkinsci.

the class PromotionProcessTest method testPromotionWithoutFingerprint.

/**
     * Tests a promotion induced by the pseudo upstream/downstream cause relationship
     */
public void testPromotionWithoutFingerprint() throws Exception {
    FreeStyleProject up = createFreeStyleProject("up");
    FreeStyleProject down = createFreeStyleProject();
    // promote if the downstream passes
    JobPropertyImpl promotion = new JobPropertyImpl(up);
    up.addProperty(promotion);
    PromotionProcess proc = promotion.addProcess("promo");
    proc.conditions.add(new DownstreamPassCondition(down.getName()));
    // trigger downstream automatically to create relationship
    up.getPublishersList().add(new BuildTrigger(down.getName(), Result.SUCCESS));
    hudson.rebuildDependencyGraph();
    // this is the downstream job
    down.getBuildersList().add(new Shell(// expr exits with non-zero status if result is zero
    "expr $BUILD_NUMBER % 2 - 1\n"));
    // not yet promoted while the downstream is failing
    FreeStyleBuild up1 = assertBuildStatusSuccess(up.scheduleBuild2(0).get());
    waitForCompletion(down, 1);
    assertEquals(0, proc.getBuilds().size());
    // do it one more time and this time it should work
    FreeStyleBuild up2 = assertBuildStatusSuccess(up.scheduleBuild2(0).get());
    waitForCompletion(down, 2);
    assertEquals(1, proc.getBuilds().size());
    {
        // verify that it promoted the right stuff
        Promotion pb = proc.getBuilds().get(0);
        assertSame(pb.getTarget(), up2);
        PromotedBuildAction badge = (PromotedBuildAction) up2.getBadgeActions().get(0);
        assertTrue(badge.contains(proc));
    }
}
Also used : Shell(hudson.tasks.Shell) DownstreamPassCondition(hudson.plugins.promoted_builds.conditions.DownstreamPassCondition) BuildTrigger(hudson.tasks.BuildTrigger) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject)

Example 18 with Shell

use of hudson.tasks.Shell 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 19 with Shell

use of hudson.tasks.Shell 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 20 with Shell

use of hudson.tasks.Shell 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)

Aggregations

Shell (hudson.tasks.Shell)25 Test (org.junit.Test)21 FreeStyleProject (hudson.model.FreeStyleProject)19 Map (java.util.Map)15 FreeStyleBuild (hudson.model.FreeStyleBuild)13 ImmutableMap (com.google.common.collect.ImmutableMap)12 Run (hudson.model.Run)4 ArtifactArchiver (hudson.tasks.ArtifactArchiver)4 List (java.util.List)3 ImmutableList (com.google.common.collect.ImmutableList)2 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)2 Project (hudson.model.Project)2 StringParameterDefinition (hudson.model.StringParameterDefinition)2 DownstreamPassCondition (hudson.plugins.promoted_builds.conditions.DownstreamPassCondition)2 Stack (java.util.Stack)2 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)2 CauseAction (hudson.model.CauseAction)1 ParametersAction (hudson.model.ParametersAction)1 Queue (hudson.model.Queue)1 StringParameterValue (hudson.model.StringParameterValue)1