use of hudson.model.StringParameterDefinition in project promoted-builds-plugin by jenkinsci.
the class SelfPromotionTest method testPromotionEnvironmentShouldIncludeTargetParameters.
@Bug(22679)
public // @Bug(34826) // Can be reproduced in Jenkins 2.3 +
void testPromotionEnvironmentShouldIncludeTargetParameters() throws Exception {
String paramName = "param";
FreeStyleProject p = createFreeStyleProject();
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition(paramName, "")));
// promote if the downstream passes
JobPropertyImpl promotion = new JobPropertyImpl(p);
p.addProperty(promotion);
PromotionProcess promo1 = promotion.addProcess("promo1");
promo1.conditions.add(new SelfPromotionCondition(false));
// ensure that the data survives the roundtrip
configRoundtrip(p);
// rebind
promotion = p.getProperty(JobPropertyImpl.class);
promo1 = promotion.getItem("promo1");
String paramValue = "someString";
FreeStyleBuild b = assertBuildStatusSuccess(p.scheduleBuild2(0, new Cause.UserCause(), new ParametersAction(new StringParameterValue(paramName, paramValue))));
// internally, the promotion is still an asynchronous process. It just happens
// right away after the build is complete.
Thread.sleep(1000);
// verify that the promotion's environment contains the parameter from the target build.
Promotion pb = promo1.getBuildByNumber(1);
assertEquals(paramValue, pb.getEnvironment(TaskListener.NULL).get(paramName, null));
}
use of hudson.model.StringParameterDefinition in project promoted-builds-plugin by jenkinsci.
the class PromotionProcessTest method testIsVisibleResolvesDefaultParameterValue.
public void testIsVisibleResolvesDefaultParameterValue() throws Exception {
FreeStyleProject project = createFreeStyleProject("project");
final List<ParameterDefinition> parameters = new ArrayList<ParameterDefinition>();
ParametersDefinitionProperty parametersProperty = new ParametersDefinitionProperty(parameters);
parameters.add(new StringParameterDefinition("Visibility", "false"));
project.addProperty(parametersProperty);
JobPropertyImpl jobProperty = new JobPropertyImpl(project);
project.addProperty(jobProperty);
PromotionProcess promotionProcess = jobProperty.addProcess("Promotion");
promotionProcess.isVisible = "${Visibility}";
assertFalse(promotionProcess.isVisible());
}
use of hudson.model.StringParameterDefinition in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method testPipelineQueue.
@Test
public void testPipelineQueue() throws Exception {
FreeStyleProject p1 = j.createFreeStyleProject("pipeline1");
p1.setConcurrentBuild(true);
p1.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("test", "test")));
p1.getBuildersList().add(new Shell("echo hello!\nsleep 300"));
p1.scheduleBuild2(0).waitForStart();
p1.scheduleBuild2(0).waitForStart();
Jenkins.getInstance().getQueue().schedule(p1, 0, new ParametersAction(new StringParameterValue("test", "test1")), new CauseAction(new Cause.UserIdCause()));
Jenkins.getInstance().getQueue().schedule(p1, 0, new ParametersAction(new StringParameterValue("test", "test2")), new CauseAction(new Cause.UserIdCause()));
List queue = request().get("/organizations/jenkins/pipelines/pipeline1/queue").build(List.class);
Assert.assertEquals(2, queue.size());
Assert.assertEquals(4, ((Map) queue.get(0)).get("expectedBuildNumber"));
Assert.assertEquals(3, ((Map) queue.get(1)).get("expectedBuildNumber"));
Assert.assertEquals("Waiting for next available executor", ((Map) queue.get(0)).get("causeOfBlockage"));
Assert.assertEquals("Waiting for next available executor", ((Map) queue.get(1)).get("causeOfBlockage"));
Run r = QueueUtil.getRun(p1, Long.parseLong((String) ((Map) queue.get(0)).get("id")));
// its not moved out of queue yet
assertNull(r);
}
Aggregations