i have my workflow set up like so. This sends an email notification when a 
job fails. 




node("slave1") {
  ws("e:\\jenkins\\workspace\\jobname\\${env.BUILD_NUMBER}") {
  try{
stage name: 'sync', concurrency: 2
  bat '''echo "before sync"
  set a=%RANDOM%
  echo %a%
  echo "after sync"'''
  sleep 10
  
stage name: 'build', concurrency: 1
  bat '''mkdir %cd%\\Build-%BUILD_NUMBER%
  dir %cd%
  cd %cd%\\Build-%BUILD_NUMBER%
  copy /y NUL EmptyFile.txt >NUL'''
  sleep 10

stage name: 'test', concurrency: 2
  bat '''dir %cd%
  dir %cd%\\Build-%BUILD_NUMBER%'''
  sleep 17
}

catch (err){
        stage 'Send Notification'
        def msgimg="https://localhost/images/some.gif";
        def newurl="${env.BUILD_URL}console"
        mail (to: '[email protected]',
             subject: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) has had 
an error.",
             body: "Ran on <b>${env.NODE_NAME}</b><br>job failed <a 
href=${newurl}>${env.JOB_NAME}</a>. Some more message.... .<br><img 
src=${msgimg} />",
             mimeType:'text/html');
        currentBuild.result = 'FAILURE'
    }

}
}


But the issue, is i am also getting email notice for jobs that were 
cancelled due to the newer job catching up with the older job while running 
concurrently. I just want email notice for jobs that actually failed due to 
some error and not be notified for jobs that were marked failed as they 
were canceled by a presiding job.  
Have anyone handled this issue? 








-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/dc1ef652-5f53-44a0-94d3-4ae0626b0dfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to