Abort jenkins job when it gets stuck

Sometimes it’s not possible to abort some jobs through the Jenkins UI.If you ever have this issue, you can abort jenkins jobs using the script console.

Go to Jenkins > Manage Jenkins > Script Console, and type in this script:

1
2
3
4
5
6
Jenkins.instance.getItemByFullName("JobName")
               .getBuildByNumber(JobNumber)
               .finish(
                       hudson.model.Result.ABORTED,
                       new java.io.IOException("Aborting build")
               );
updatedupdated2024-01-172024-01-17