Running a Post Build script when a Jenkins job is aborted

走远了吗. 提交于 2019-12-03 04:52:31

This question is positively answered here.

The Post Build Task plugin is run even if a job is aborted.

Use it to search the log text for "Build was aborted" and you can specify a shell script to run.

Works like a charm. :-)

As far as I know, if a build is aborted, there's no way to execute any build steps (or post build steps) in it any more - which makes sense, that's what I would expect of "abort".

What you could do is create another job that monitors the first one's status, and triggers if it was aborted (e.g. see the BuildResultTrigger plugin).

Another solution might be to create a "wrapper" job, which calls the first one as a build step - this way you can execute additional steps after its completion, like checking its status, even if it was aborted.

anuj0901

If you use a scripted pipeline, you can always use a try/catch/finally set, where the build gets executed in the try block and the postbuild steps are in the finally block. This way, even if the build fails, post build steps are executed.

try {
        build here
}catch(FlowInterruptedException interruptEx){

    catch exception here
} finally {

    postBuild(parameters)

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!