use of hudson.model.FreeStyleProject in project promoted-builds-plugin by jenkinsci.
the class PromotionProcessTest method testIsVisibleFalseReturnsNotVisible.
public void testIsVisibleFalseReturnsNotVisible() throws Exception {
FreeStyleProject project = createFreeStyleProject("project");
JobPropertyImpl jobProperty = new JobPropertyImpl(project);
project.addProperty(jobProperty);
PromotionProcess promotionProcess = jobProperty.addProcess("Promotion");
promotionProcess.isVisible = "false";
assertFalse(promotionProcess.isVisible());
}
use of hudson.model.FreeStyleProject 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));
}
}
use of hudson.model.FreeStyleProject in project promoted-builds-plugin by jenkinsci.
the class PromotionTargetActionTest method test1.
/**
* When a project is created, built, and renamed, then the old build is created,
* that results in NPE.
*/
public void test1() throws Exception {
FreeStyleProject up = createFreeStyleProject("up");
up.setCustomWorkspace(createTmpDir().getPath());
// promote if the downstream passes
JobPropertyImpl promotion = new JobPropertyImpl(up);
up.addProperty(promotion);
PromotionProcess proc = promotion.addProcess("promo");
proc.conditions.add(new ManualCondition());
FreeStyleBuild b = assertBuildStatusSuccess(up.scheduleBuild2(0));
b.addAction(new ManualApproval(proc.getName(), Collections.<ParameterValue>emptyList()));
b.save();
// check for promotion
Promotion p = assertBuildStatusSuccess(proc.considerPromotion2(b));
up.renameTo("up2");
assertSame(b, p.getTarget());
}
use of hudson.model.FreeStyleProject in project promoted-builds-plugin by jenkinsci.
the class RemoteApiTest method delete.
@Test
public void delete() throws Exception {
FreeStyleProject p = r.createFreeStyleProject("p");
JobPropertyImpl promotion = new JobPropertyImpl(p);
p.addProperty(promotion);
promotion.addProcess("promo").save();
assertEquals(1, promotion.getItems().size());
assertEquals(1, promotion.getActiveItems().size());
JenkinsRule.WebClient wc = r.createWebClient();
wc.getPage(wc.addCrumb(new WebRequest(new URL(r.getURL(), "job/p/promotion/process/promo/doDelete"), HttpMethod.POST)));
assertEquals(0, promotion.getItems().size());
assertEquals(0, promotion.getActiveItems().size());
}
use of hudson.model.FreeStyleProject in project promoted-builds-plugin by jenkinsci.
the class RemoteApiTest method acl.
@Test
public void acl() throws Exception {
r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
ProjectMatrixAuthorizationStrategy pmas = new ProjectMatrixAuthorizationStrategy();
r.jenkins.setAuthorizationStrategy(pmas);
pmas.add(Jenkins.READ, "anonymous");
FreeStyleProject p = r.createFreeStyleProject("p");
Map<Permission, Set<String>> perms = new HashMap<Permission, Set<String>>();
perms.put(Item.READ, Collections.singleton("alice"));
perms.put(Item.CONFIGURE, Collections.singleton("alice"));
perms.put(Item.DISCOVER, Collections.singleton("bob"));
p.addProperty(new AuthorizationMatrixProperty(perms));
JobPropertyImpl promotion = new JobPropertyImpl(p);
p.addProperty(promotion);
promotion.addProcess("promo").save();
JenkinsRule.WebClient wc = r.createWebClient();
wc.assertFails("job/p/promotion/process/promo/config.xml", HttpURLConnection.HTTP_NOT_FOUND);
wc.login("bob");
wc.assertFails("job/p/promotion/process/promo/config.xml", HttpURLConnection.HTTP_FORBIDDEN);
wc.login("alice");
wc.goToXml("job/p/config.xml");
wc.goToXml("job/p/promotion/process/promo/config.xml");
}
Aggregations