j.assertBuildStatusSuccess(us.scheduleBuild2(0));
assertEquals(1, ds.getBuilds().size());
}
@Test public void parameters() throws Exception {
WorkflowJob us = j.jenkins.createProject(WorkflowJob.class, "us");
FreeStyleProject ds = j.jenkins.createProject(FreeStyleProject.class, "ds");
ds.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("branch", "master"), new BooleanParameterDefinition("extra", false, null)));
ds.getBuildersList().add(new Shell("echo branch=$branch extra=$extra"));
us.setDefinition(new CpsFlowDefinition("build 'ds'"));
WorkflowRun us1 = j.assertBuildStatusSuccess(us.scheduleBuild2(0));
FreeStyleBuild ds1 = ds.getBuildByNumber(1);
j.assertLogContains("branch=master extra=false", ds1);
Cause.UpstreamCause cause = ds1.getCause(Cause.UpstreamCause.class);
assertNotNull(cause);
assertEquals(us1, cause.getUpstreamRun());
// TODO https://trello.com/c/d4gxlcQJ/78-parameterdefinition-create-object would be useful to let us bind a simple Groovy map
us.setDefinition(new CpsFlowDefinition("build job: 'ds', parameters: [new hudson.model.StringParameterValue('branch', 'release')]"));
j.assertBuildStatusSuccess(us.scheduleBuild2(0));
// TODO IIRC there is an open PR regarding automatic filling in of default parameter values; should that be used, or is BuildTriggerStepExecution responsible, or ParameterizedJobMixIn.scheduleBuild2?
j.assertLogContains("branch=release extra=", ds.getBuildByNumber(2));
us.setDefinition(new CpsFlowDefinition("build job: 'ds', parameters: [new hudson.model.StringParameterValue('branch', 'release'), new hudson.model.BooleanParameterValue('extra', true)]"));
j.assertBuildStatusSuccess(us.scheduleBuild2(0));
j.assertLogContains("branch=release extra=true", ds.getBuildByNumber(3));
}