Reputation: 367
I am using Jenkinsfile to do build and send mail. Problem is my mail functionality is working when build status gets changed i.e. success to fail and fail to success. I want every time it should shoot mail when build is completed.
stage('Mail'){
currentBuild.result = "SUCCESS"
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: '[email protected]', sendToIndividuals: true])
}
}
catch (err) {
currentBuild.result = "FAILURE"
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: '[email protected]', sendToIndividuals: true])
throw err
}
finally{
if(currentBuild.result=='SUCCESS'){
}
}
I tried to find few solutions, but was unsuccessful. Aman
Upvotes: 0
Views: 708
Reputation: 2882
Putting the code in the finally block without the If check will cause the Mailer step to fire regardless of build result.
Upvotes: 1