" sh('echo after=`basename $PWD`')\n" +
" }\n" +
"}"
));
p.save();
WorkflowRun b1 = p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("FLAG", "one"))).waitForStart();
CpsFlowExecution e1 = (CpsFlowExecution) b1.getExecutionPromise().get();
while (watchDescriptor.getActiveWatches().isEmpty()) {
assertTrue(JenkinsRule.getLog(b1), b1.isBuilding());
waitForWorkflowToSuspend(e1);
}
WorkflowRun b2 = p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("FLAG", "two"))).waitForStart();
CpsFlowExecution e2 = (CpsFlowExecution) b2.getExecutionPromise().get();
while (watchDescriptor.getActiveWatches().size() == 1) {
assertTrue(JenkinsRule.getLog(b2), b2.isBuilding());
waitForWorkflowToSuspend(e2);
}
}
});
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
rebuildContext(story.j);
WorkflowRun b1 = p.getBuildByNumber(1);
CpsFlowExecution e1 = (CpsFlowExecution) b1.getExecution();
assertThatWorkflowIsSuspended(b1, e1);
WorkflowRun b2 = p.getBuildByNumber(2);
CpsFlowExecution e2 = (CpsFlowExecution) b2.getExecution();
assertThatWorkflowIsSuspended(b2, e2);
FileUtils.write(new File(jenkins().getRootDir(), "one"), "here");
FileUtils.write(new File(jenkins().getRootDir(), "two"), "here");
story.j.waitUntilNoActivity();
assertBuildCompletedSuccessfully(b1);
assertBuildCompletedSuccessfully(b2);
story.j.assertLogContains("default=demo", b1);
story.j.assertLogContains("before=demo@2", b1);
story.j.assertLogContains("after=demo@2", b1);
story.j.assertLogContains("default=demo@3", b2);
story.j.assertLogContains("before=demo@4", b2);
story.j.assertLogContains("after=demo@4", b2);
FileUtils.write(new File(jenkins().getRootDir(), "three"), "here");
WorkflowRun b3 = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("FLAG", "three"))));
story.j.assertLogContains("default=demo", b3);
story.j.assertLogContains("before=demo@2", b3);
story.j.assertLogContains("after=demo@2", b3);
}
});