Search code examples
jenkinsjenkins-pipelinejenkins-groovyjenkins-job-dsl

Send email to users irrespective of jenkins job status in scripted pipeline


  • I have Jenkins groovy scripted pipeline job and which has multiple stages and in one of the stage it will trigger the another job and in the end it will trigger the email and it is sending email only if all the stages passed successfully and if in one of the stage has issue, pipeline is stopping execution there itself but I needs to trigger email irrespective of stage failure in groovy scripted pipeline.*

Solution

  • You can wrap the execution blocks in Stages with try-catch blocks and decide what you want to do if an error occurs in the catch block.