@Issue("JENKINS-45455") @Test public void stashAndRestart() throws Exception { WorkflowRun original = expect(Result.FAILURE, "restart", "stashAndRestart").go(); WorkflowJob p = original.getParent(); HtmlPage redirect = restartFromStageInUI(original, "restart"); assertNotNull(redirect); assertEquals(p.getAbsoluteUrl(), redirect.getUrl().toString()); j.waitUntilNoActivity(); WorkflowRun b2 = p.getBuildByNumber(2); assertNotNull(b2); j.assertBuildStatusSuccess(b2); j.assertLogContains("Even numbered build, success", b2); j.assertLogContains("Stage \"pre-restart\" skipped due to this build restarting at stage \"restart\"", b2); j.assertLogContains("someFile is some text", b2); }
@Issue("JENKINS-45455") @Test public void isRestartedRunCondition() throws Exception { WorkflowRun original = expect("restart", "isRestartedRunCondition") .logContains("This shouldn't show up on second run") .logNotContains("This should only run on restart") .go(); WorkflowJob p = original.getParent(); HtmlPage redirect = restartFromStageInUI(original, "restart"); assertNotNull(redirect); assertEquals(p.getAbsoluteUrl(), redirect.getUrl().toString()); j.waitUntilNoActivity(); WorkflowRun b2 = p.getBuildByNumber(2); assertNotNull(b2); j.assertBuildStatusSuccess(b2); j.assertLogContains("This should only run on restart", b2); j.assertLogNotContains("This shouldn't show up on second run", b2); }
assertThat(restartableStages, is(Arrays.asList("skip-on-restart", "restart"))); HtmlPage redirect = restartFromStageInUI(original, "restart");
assertThat(restartableStages, is(Arrays.asList("skip-on-restart", "restart"))); HtmlPage redirect = restartFromStageInUI(original, "restart");
@Issue("JENKINS-45455") @Test public void nestedStagesSkippedOnRestart() throws Exception { WorkflowRun original = expect(Result.FAILURE, "restart", "nestedStagesSkippedOnRestart").go(); WorkflowJob p = original.getParent(); HtmlPage redirect = restartFromStageInUI(original, "restart"); assertNotNull(redirect); assertEquals(p.getAbsoluteUrl(), redirect.getUrl().toString()); j.waitUntilNoActivity(); WorkflowRun b2 = p.getBuildByNumber(2); assertNotNull(b2); j.assertBuildStatusSuccess(b2); j.assertLogContains("Even numbered build, success", b2); j.assertLogContains("Stage \"parallel-pre-restart\" skipped due to this build restarting at stage \"restart\"", b2); j.assertLogContains("Stage \"first-parallel-skipped\" skipped due to this build restarting at stage \"restart\"", b2); j.assertLogContains("Stage \"second-parallel-skipped\" skipped due to this build restarting at stage \"restart\"", b2); j.assertLogContains("Stage \"sequence-pre-restart\" skipped due to this build restarting at stage \"restart\"", b2); j.assertLogContains("Stage \"first-sequence-skipped\" skipped due to this build restarting at stage \"restart\"", b2); j.assertLogContains("Stage \"second-sequence-skipped\" skipped due to this build restarting at stage \"restart\"", b2); j.assertLogContains("Made it to post-restart", b2); }
sampleRepo.git("commit", "--message=poof"); HtmlPage redirect = restartFromStageInUI(failing, "restart");
@Issue("JENKINS-45455") @Test public void sameJenkinsfileNonMultibranch() throws Exception { // This test verifies that the Jenkinsfile is the same across both builds, even if the SCM has changed. // Since we're not a multibranch here, the actual checkout does change, though. WorkflowRun original = expect(Result.FAILURE, "restart", "sameJenkinsfileNonMultibranch").go(); WorkflowJob p = original.getParent(); // Make SCM changes now. sampleRepo.write("Jenkinsfile", pipelineSourceFromResources("restart/sameJenkinsfileNonMultibranchSecond")); sampleRepo.write("newFile", "exists"); sampleRepo.git("add", "Jenkinsfile"); sampleRepo.git("add", "newFile"); sampleRepo.git("commit", "--message=later"); HtmlPage redirect = restartFromStageInUI(original, "restart"); assertNotNull(redirect); assertEquals(p.getAbsoluteUrl(), redirect.getUrl().toString()); j.waitUntilNoActivity(); WorkflowRun b2 = p.getBuildByNumber(2); assertNotNull(b2); j.assertBuildStatusSuccess(b2); j.assertLogContains("Even numbered build, success", b2); j.assertLogContains("Stage \"skip-on-restart\" skipped due to this build restarting at stage \"restart\"", b2); j.assertLogNotContains("Now we're post-restart", b2); j.assertLogNotContains("hello on non-restart", b2); j.assertLogContains("Stage \"post-restart\" skipped due to when conditional", b2); }
@Issue("JENKINS-45455") @Test public void parametersAndRestart() throws Exception { // Initial build passes - we mainly just want it to add the parameters. WorkflowRun original = expect("restart", "parametersAndRestart").go(); WorkflowJob p = original.getParent(); WorkflowRun failing = p.scheduleBuild2(0, new ParametersAction(new BooleanParameterValue("flag", false), new StringParameterValue("someParam", "changed"))).waitForStart(); j.assertBuildStatus(Result.FAILURE, j.waitForCompletion(failing)); HtmlPage redirect = restartFromStageInUI(failing, "restart"); assertNotNull(redirect); assertEquals(p.getAbsoluteUrl(), redirect.getUrl().toString()); j.waitUntilNoActivity(); WorkflowRun b3 = p.getBuildByNumber(3); assertNotNull(b3); j.assertBuildStatusSuccess(b3); j.assertLogContains("Odd numbered build, success", b3); j.assertLogContains("Stage \"pre-restart\" skipped due to this build restarting at stage \"restart\"", b3); j.assertLogContains("Flag is false", b3); j.assertLogContains("someParam is changed", b3); j.assertLogContains("otherParam is should not change", b3); j.assertLogNotContains("hello on non-restart", b3); }
sampleRepo.git("commit", "--message=later"); HtmlPage redirect = restartFromStageInUI(b1, "restart");