I have the following build pipeline set up as a job:
Stage 1 - verify all dependencies exist
Stage 2 - build the new jar
Stage 3 - Run integration tests
Stage 4 - Deploy to staging environment (manual step)
Stage 5 - Deploy to production environment (manual step)
I am looking for a way to start the build pipeline from a particular stage in case of a transient failure. For example, let's say there was a network issue when the user clicked to deploy to production. I don't think it makes sense to start the pipeline from stage 1... I'd like to try that step again and continue on from there in the pipeline. I don't see any functionality like this in the Build Pipeline Plugin.
Thanks!!
Once your Pipeline has completed, whether it succeeds or fails, you can go to the side panel for the run in the classic UI and click on "Restart from Stage". You will be prompted to choose from a list of top-level stages that were executed in the original run, in the order they were executed.
The Jenkins Replay Button It is somewhat similar to the Rebuild button but allows you to edit the Jenkinsfile just before running the job. Jut inline edit the code and click the run button.
To retry a Jenkins job, you can use the Naginator plugin. Simply install the plugin, and then check the Post-Build action "Retry build after failure" on your project's configuration page. If the build fails, it will be rescheduled to run again after the time you specified.
Meanwhile, many other answers are obsolete, as Jenkins provides a built-in solution that allows you to restart a job from any stage: https://jenkins.io/doc/book/pipeline/running-pipelines/ It is applicable to declarative pipeline only through.
checkpoint
is what you are looking for. Unfortunately it is only available in the CloudBees Jenkins Enterprise suite, not in the free version.
Let's hope it makes it into the open-source version as it seems to be a very common use case.
A better solution is a solution similar to what I suggested in this question:
Write a pipelining script that has has "if"-guards around the single stages, like this:
stage "s1"
if (theStage in ["s1"]) {
sleep 2
}
stage "s2"
if (theStage in ["s1", "s2"]) {
sleep 2
}
stage "s3"
if (theStage in ["s1", "s2", "s3"]) {
sleep 2
}
Then you can make a "main" job that uses this script and runs all stages at once by setting the parameter "theStage" to "s1". This job will collect the statistics when all stages are run at once and give you useful estimation times.
Furthermore, you can make a "partial run" job that uses this script and that is parametrized with the stage that you want to start with. The estimation will not be very useful, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With