0

In my jenkins i have 2 different jobs, will be scheduled to call at 15 mins timelap. I am sending an separate emails for both the jobs with status.

I want to send an single email for both the jobs, once both jobs are get executed Could some suggest me how to send 1 email for n number of jobs with each jobs status is noted in body of the email.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Harris
  • 1
  • 1
  • 1

1 Answers1

0

The easiest way would be to trigger both jobs with a pipeline job something like (untested)

def resulta
def resultb
parallel a: {
   resulta = build 'joba'
}, b: {
   resultb = build 'jobb'
}
emailext body: "Joba: ${resulta.result} Jobb: ${resultb.result}", subject: 'Job Status', to: 'test@example.com'
David van Laatum
  • 634
  • 4
  • 13
  • Hello David, Thanks for the quick response, could you please provide the steps to do above solution – Harris Nov 17 '17 at 13:27
  • There is a job type called pipeline that allows you to use groovy code to perform the build see https://wiki.jenkins.io/x/z4N2B – David van Laatum Nov 18 '17 at 23:27
  • I have tried with Pipeline job and try to execute above groovy code but still i am not able to build the jobs. – Harris Nov 27 '17 at 09:18
  • I think above script is not able to build the job – Harris Nov 27 '17 at 09:19
  • what happens when you try the above? (I just fixed an error) – David van Laatum Nov 27 '17 at 09:21
  • Thankyou somuch...I can able to run both jobs and get the result of the jobs..:) – Harris Nov 27 '17 at 11:17
  • Earlier, I have used customized groovy template for separate email. Now, How can i use the same template in place of above of code. – Harris Nov 27 '17 at 11:19
  • emailext body: '''${SCRIPT, template="groovy-html-custom.template"}''', subject: "Jobs Status", to: "abc@gmail.com" This gives only current job(Pipeline Job) Result. How can i use the template to display the both sub jobs results and details. – Harris Nov 27 '17 at 12:39
  • You will have to make a custom template to do that it’s not designed for multiple jobs – David van Laatum Nov 28 '17 at 06:03
  • In the above example, i can able to get results if joba or jobb is passed. I am not able to get result when any job is fail. And even any of the job is failed mail also not able to trigger. How can i get result even failed jobs as well. joba or jobb is failed i need to get result for both the jobs and mail need to trigger with both jobs results. ----Please help me on this... – Harris Nov 29 '17 at 10:17
  • build job: 'joba', propagate: false see the built in documentation for the build step – David van Laatum Dec 01 '17 at 11:19