Consolidate the Downstream job emails

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Consolidate the Downstream job emails

sravan
Hi Guys,
I have 3 jobs which are running as pipeline

Job A
Downstream job is
Job B
Downstream job is
Job c

Currently it send 3 different emails for 3 different jobs

How can I get one email with all the job results 

Any help is appreciated

Thanks,
Sravan

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/621d6b36-0b85-42e5-9ca2-db6244341c48%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Consolidate the Downstream job emails

sravan
Hi,
Could Someone help me with  that his please

On Friday, August 23, 2019 at 3:25:38 PM UTC-7, sravan wrote:
Hi Guys,
I have 3 jobs which are running as pipeline

Job A
Downstream job is
Job B
Downstream job is
Job c

Currently it send 3 different emails for 3 different jobs

How can I get one email with all the job results 

Any help is appreciated

Thanks,
Sravan

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/35a1b65e-f676-4723-a0b4-4dd6af66abc2%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Consolidate the Downstream job emails

Arnaud bourree
What do you expect in your consolidated email?
If job A calsl job B which calls job C, you can add email part parameter in job B and C.
If job C knows that job A and B run before, it could fetch information from previous job's artefacts on simply gets jobs result. 


Le lun. 26 août 2019 à 19:03, sravan <[hidden email]> a écrit :
Hi,
Could Someone help me with  that his please

On Friday, August 23, 2019 at 3:25:38 PM UTC-7, sravan wrote:
Hi Guys,
I have 3 jobs which are running as pipeline

Job A
Downstream job is
Job B
Downstream job is
Job c

Currently it send 3 different emails for 3 different jobs

How can I get one email with all the job results 

Any help is appreciated

Thanks,
Sravan

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/35a1b65e-f676-4723-a0b4-4dd6af66abc2%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAESUf_CHY1Fs%3DeGyoHyWPW_pOkTaMO7VLPsA9oU9mV84XM93JQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Consolidate the Downstream job emails

sravan
Job results of the three jobs in one email. Rather than it sending 3 different emails

On Monday, August 26, 2019 at 10:44:12 PM UTC-7, Arnaud wrote:
What do you expect in your consolidated email?
If job A calsl job B which calls job C, you can add email part parameter in job B and C.
If job C knows that job A and B run before, it could fetch information from previous job's artefacts on simply gets jobs result. 


Le lun. 26 août 2019 à 19:03, sravan <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="9Z6n8Cq_EAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">skkamb...@...> a écrit :
Hi,
Could Someone help me with  that his please

On Friday, August 23, 2019 at 3:25:38 PM UTC-7, sravan wrote:
Hi Guys,
I have 3 jobs which are running as pipeline

Job A
Downstream job is
Job B
Downstream job is
Job c

Currently it send 3 different emails for 3 different jobs

How can I get one email with all the job results 

Any help is appreciated

Thanks,
Sravan

--
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 <a href="javascript:" rel="nofollow" target="_blank" gdf-obfuscated-mailto="9Z6n8Cq_EAAJ" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/35a1b65e-f676-4723-a0b4-4dd6af66abc2%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/35a1b65e-f676-4723-a0b4-4dd6af66abc2%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/35a1b65e-f676-4723-a0b4-4dd6af66abc2%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/35a1b65e-f676-4723-a0b4-4dd6af66abc2%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0687d217-3207-4ace-b78c-e4d012b98a44%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Consolidate the Downstream job emails

ankit kapoor
How to set different email addresses for different jobs ? any groovy script is required ? please help me on same ?

On Tue, Aug 27, 2019 at 11:18 AM sravan <[hidden email]> wrote:
Job results of the three jobs in one email. Rather than it sending 3 different emails

On Monday, August 26, 2019 at 10:44:12 PM UTC-7, Arnaud wrote:
What do you expect in your consolidated email?
If job A calsl job B which calls job C, you can add email part parameter in job B and C.
If job C knows that job A and B run before, it could fetch information from previous job's artefacts on simply gets jobs result. 


Le lun. 26 août 2019 à 19:03, sravan <[hidden email]> a écrit :
Hi,
Could Someone help me with  that his please

On Friday, August 23, 2019 at 3:25:38 PM UTC-7, sravan wrote:
Hi Guys,
I have 3 jobs which are running as pipeline

Job A
Downstream job is
Job B
Downstream job is
Job c

Currently it send 3 different emails for 3 different jobs

How can I get one email with all the job results 

Any help is appreciated

Thanks,
Sravan

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/35a1b65e-f676-4723-a0b4-4dd6af66abc2%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0687d217-3207-4ace-b78c-e4d012b98a44%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAOCfY-Q4TbxM3gq0x2amrGU3o3R5p8VRLCU2Mqg%3D2x5zKKDKzQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Consolidate the Downstream job emails

Dirk Heinrichs-3
In reply to this post by sravan
Am Freitag, den 23.08.2019, 15:24 -0700 schrieb sravan:

How can I get one email with all the job results 

If job A was a Multijob, you can do this using Extended Email plugin together with a pre-send script which traverses the sub jobs to get their results and prepare the email body.

Sample script:

// Scan all downstream jobs of a MultiJob and prepare the final email text

import hudson.model.*
import com.tikal.jenkins.plugins.multijob.*

// Get some environment vars
def url = build.envVars['JENKINS_URL'].replaceAll('/*$', '')

// Set summary header
def result = build.getResult()
def h2 = ''
switch (result) {
  case 'ABORTED':
    h2 = '''<h2>Your job was aborted</h2>
<h3>Aborts usually have one of two reasons:</h3>
<ol>
  <li>Manual abort</li>
  <li>Timeout</li>
</ol>'''
    break
  case 'FAILURE':
    h2 = '<h2>Your job has failed</h2>'
    break
  case 'SUCCESS':
    h2 = '<h2>Your job was successfull</h2>'
    break
}
def header = h2
header += '<h3>Job status summary</h3>'
header += '<a href="' + url + '/' + build.getUrl() + '">' + build.getProject().getFullName() + ' #' + build.getNumber() + ': ' + result + '</a>'
header += '<ul style="list-style: none; ">'

// Initialize data structure
def data = [
  subJobs: 0,
  failed: false,
  sum: header,
  url: url
]

// Recursive method to create status summary for all sub jobs
// Params:
//   - job: a multijob object
//   - a data structure as defined above
// Returns:
//   - A modified data structure with updated sum and failed fields
Map collectResults(build, data) {
  // Iterate over sub builds
  build.getSubBuilds().each { subBuild ->
    def theBuild = subBuild.getBuild()
    data['subJobs'] += 1
    // Get sub build's metadata
    def subName = theBuild.getProject().getFullName()
    def subNumber = subBuild.getBuildNumber()
    def subUrl = data['url'] + '/' + subBuild.getUrl()
    def result = subBuild.getResult()
    def failed = (result == "FAILURE")

    // Update overall status
    data['failed'] = data['failed'] || failed

    // Append to summary
    data['sum'] += '<li><a href="' + subUrl + '">' + subName + ' #' + subNumber + ': ' + result + '</a></li>'

    // Recurse, if current sub build is a MultiJobBuild itself
    if (theBuild instanceof com.tikal.jenkins.plugins.multijob.MultiJobBuild) {
      data['sum'] += '<li><ul style="list-style: none; ">'
      data = collectResults(theBuild, data)
      data['sum'] += '</ul></li>'
    }
  }
  return data
}

try {
  // Collect results of all sub jobs
  data = collectResults(build, data)

  def summary = data['sum']
  summary += '</ul>'
  summary += '<h3>Additional information</h3>'
  summary += '<a href="' + build.envVars['JOB_URL'] + '">Main job page</a><br>'

  // Set message body
  msg.setContent(summary, 'text/html')
}
catch(Exception e) {
  log("ERROR: ${e.message}")
  log("ERROR: Failed status report aggregation")
}


HTH...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e3d2c822303ea51d82f98cb7eb9452f38912e98d.camel%40opentext.com.