@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());
   us.setDefinition(
       new CpsFlowDefinition(
           "build job: 'ds', parameters: [[$class: 'StringParameterValue', name: 'branch', value: 'release']]",
           true));
   j.assertBuildStatusSuccess(us.scheduleBuild2(0));
   // TODO JENKINS-13768 proposes 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: [[$class: 'StringParameterValue', name: 'branch', value: 'release'], [$class: 'BooleanParameterValue', name: 'extra', value: true]]",
           true));
   j.assertBuildStatusSuccess(us.scheduleBuild2(0));
   j.assertLogContains("branch=release extra=true", ds.getBuildByNumber(3));
 }
  @Test
  public void abortBuild() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject("test1");
    p.getBuildersList().add(new Shell("sleep 6000"));

    WorkflowJob foo = j.jenkins.createProject(WorkflowJob.class, "foo");
    foo.setDefinition(
        new CpsFlowDefinition(StringUtils.join(Arrays.asList("build('test1');"), "\n")));

    QueueTaskFuture<WorkflowRun> q = foo.scheduleBuild2(0);
    WorkflowRun b = q.getStartCondition().get();

    CpsFlowExecution e = (CpsFlowExecution) b.getExecutionPromise().get();
    e.waitForSuspension();

    FreeStyleBuild fb = null;
    while (fb == null) {
      fb = p.getBuildByNumber(1);
      Thread.sleep(10);
    }
    fb.getExecutor().interrupt();

    j.assertBuildStatus(Result.ABORTED, j.waitForCompletion(fb));
    j.assertBuildStatus(Result.FAILURE, q.get());
  }
  @LocalData
  @Test
  public void persistence() throws Exception {
    project.scheduleBuild2(0).get(60, TimeUnit.SECONDS);

    reloadJenkins();

    FreeStyleBuild build = project.getBuildByNumber(1);

    assertTestResults(build);
  }