I have a lengthy Jenkins job with a failing post-build action.
How can I repeatedly run the post-build action without re-running the whole job?
If splitting the job into 2 jobs is not an option, you may consider
https://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin
(this is pre-installed with Jenkins I believe). This will make the "promotion" steps a separate and repeatable process. You can configure it to run automatically after build, and then manually on demand when needed.
If your post-build steps require access to build artifacts, you will need to use https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin to copy the build artifacts to the promotion's workspace.
Another solution is to skip build step based on parameter. Have a Choice parameter called SkipBuild or something. Set the possible values to TRUE/FALSE, default to FALSE
In your Build step, before actually building, check if SkipBuild is set to TRUE. If TRUE, exit 0, if FALSE (which is default) then run build command.
This way, automatic Build executions will always run the Build step. But you can also manually run the build and select "SkipBuild=TRUE" to skip the build step and go straight to post-build actions. If you need to skip some post-build actions, you would need to implement this SkipBuild parameter there as well.
Careful however as subsequent executions of the build, even with "SkipBuild=TRUE" will still perform an SVN checkout, so your workspace may change.
Depending on what your build steps are, you might be able to 'skip' them.
For example, my build steps are powershell and windows batch files.
If I want to skip a step I simply add 'exit 0' as the first line of the powershell or batch command.
Be aware this WILL still result in other pre-build steps, like workspace cleanup and scm checkouts being run.
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