use of hudson.tasks.Shell 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());
}
use of hudson.tasks.Shell 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);
}
use of hudson.tasks.Shell 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());
}
use of hudson.tasks.Shell in project blueocean-plugin by jenkinsci.
the class ArtifactContainerImplTest method testArtifactsListing.
@Test
public void testArtifactsListing() throws Exception {
FreeStyleProject p = j.createFreeStyleProject(JOB_NAME);
p.getBuildersList().add(new Shell("#!/bin/bash\nmkdir -p test/me/out; cd test/me/out; touch {0..105}.txt"));
p.getPublishersList().add(new ArtifactArchiver("**/*"));
Run r = p.scheduleBuild2(0).waitForStart();
r = j.waitForCompletion(r);
List artifacts = request().get("/organizations/jenkins/pipelines/" + JOB_NAME + "/runs/" + r.getId() + "/artifacts").build(List.class);
Assert.assertEquals(100, artifacts.size());
Assert.assertEquals(0, ((Map) artifacts.get(0)).get("size"));
Assert.assertEquals("test/me/out/0.txt", ((Map) artifacts.get(0)).get("path"));
Assert.assertEquals("/job/artifactTest/1/artifact/test/me/out/0.txt", ((Map) artifacts.get(0)).get("url"));
}
use of hudson.tasks.Shell in project promoted-builds-plugin by jenkinsci.
the class PromotionProcessTest method test1.
public void test1() throws Exception {
FreeStyleProject up = createFreeStyleProject("up");
FreeStyleProject down = createFreeStyleProject();
List<Recorder> recorders = Arrays.asList(new ArtifactArchiver("a.jar", null, false), new Fingerprinter("", true));
// upstream job
up.getBuildersList().add(new Shell("date > a.jar"));
up.getPublishersList().replaceBy(recorders);
// 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()));
// this is the test job
String baseUrl = new WebClient().getContextPath() + "job/up/lastSuccessfulBuild";
down.getBuildersList().add(new Shell("wget -N " + baseUrl + "/artifact/a.jar \\\n" + " || curl " + baseUrl + "/artifact/a.jar > a.jar\n" + // expr exits with non-zero status if result is zero
"expr $BUILD_NUMBER % 2 - 1\n"));
down.getPublishersList().replaceBy(recorders);
// fire ItemListeners, this includes ArtifactArchiver,Migrator to make this test compatible with jenkins 1.575+
fireItemListeners();
// not yet promoted while the downstream is failing
FreeStyleBuild up1 = assertBuildStatusSuccess(up.scheduleBuild2(0).get());
assertBuildStatus(Result.FAILURE, down.scheduleBuild2(0).get());
// give it a time to not promote
Thread.sleep(1000);
assertEquals(0, proc.getBuilds().size());
// a successful downstream build promotes upstream
assertBuildStatusSuccess(down.scheduleBuild2(0).get());
// give it a time to promote
Thread.sleep(1000);
assertEquals(1, proc.getBuilds().size());
{
// verify that it promoted the right stuff
Promotion pb = proc.getBuilds().get(0);
assertSame(pb.getTarget(), up1);
PromotedBuildAction badge = (PromotedBuildAction) up1.getBadgeActions().get(0);
assertTrue(badge.contains(proc));
}
// make sure the UI persists the setup
configRoundtrip(up);
}
Aggregations