This PR sets the e-mailer to only notify if the build result has changed. In lieu of threaded emails, this simply reduces the amount of jenkins spam sent to the list/owner. Testing this is interesting since you have to break something and then fix it somewhere in the pipeline steps above. I did this using something like the following pipeline:
try{// massive try{} catch{} around the entire build for failure notificationsnode('master'){stage('Invoke Flake8'){// change this to false to fail the job <<<<<sh'true'}}}catch(e){currentBuild.result='FAILURE'throwe}finally{defcurrentResult=currentBuild.result?:'SUCCESS'defpreviousResult=currentBuild.previousBuild?.resultdefSUBJECT=''defBODY="${env.BUILD_URL}"if(previousResult=='FAILURE'&¤tResult=='SUCCESS'){SUBJECT="Jenkins job ${env.JOB_NAME} #${env.BUILD_NUMBER} fixed."}elseif(previousResult=='SUCCESS'&¤tResult=='FAILURE'){SUBJECT="Jenkins job ${env.JOB_NAME} #${env.BUILD_NUMBER} failed."}if(SUBJECT!=''){emailextto:ownership.job.primaryOwnerEmail,subject:SUBJECT,body:BODY}}
Running this multiple times and changing the sh step's return value you can see the pattern of emails on status changes.
This PR sets the e-mailer to only notify if the build result has changed. In lieu of threaded emails, this simply reduces the amount of jenkins spam sent to the list/owner. Testing this is interesting since you have to break something and then fix it somewhere in the pipeline steps above. I did this using something like the following pipeline:
Running this multiple times and changing the sh step's return value you can see the pattern of emails on status changes.