Re: Consolidate the Downstream job emails

2019-08-27 Thread Dirk Heinrichs
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 = '''Your job was aborted
Aborts usually have one of two reasons:

  Manual abort
  Timeout
'''
break
  case 'FAILURE':
h2 = 'Your job has failed'
break
  case 'SUCCESS':
h2 = 'Your job was successfull'
break
}
def header = h2
header += 'Job status summary'
header += '' + 
build.getProject().getFullName() + ' #' + build.getNumber() + ': ' + result + 
''
header += ''

// 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'] += '' + subName + ' #' + subNumber 
+ ': ' + result + ''

// Recurse, if current sub build is a MultiJobBuild itself
if (theBuild instanceof com.tikal.jenkins.plugins.multijob.MultiJobBuild) {
  data['sum'] += ''
  data = collectResults(theBuild, data)
  data['sum'] += ''
}
  }
  return data
}

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

  def summary = data['sum']
  summary += ''
  summary += 'Additional information'
  summary += 'Main job page'

  // 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
Email: dhein...@opentext.com
Website: www.recommind.de
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/e3d2c822303ea51d82f98cb7eb9452f38912e98d.camel%40opentext.com.


Re: Consolidate the Downstream job emails

2019-08-27 Thread 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  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  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 jenkins...@googlegroups.com.
>>> 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 jenkinsci-users+unsubscr...@googlegroups.com.
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAOCfY-Q4TbxM3gq0x2amrGU3o3R5p8VRLCU2Mqg%3D2x5zKKDKzQ%40mail.gmail.com.


Re: Consolidate the Downstream job emails

2019-08-26 Thread 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 é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 jenkins...@googlegroups.com .
>> 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/0687d217-3207-4ace-b78c-e4d012b98a44%40googlegroups.com.


Re: Consolidate the Downstream job emails

2019-08-26 Thread 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  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 jenkinsci-users+unsubscr...@googlegroups.com.
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAESUf_CHY1Fs%3DeGyoHyWPW_pOkTaMO7VLPsA9oU9mV84XM93JQ%40mail.gmail.com.


Consolidate the Downstream job emails

2019-08-23 Thread 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/621d6b36-0b85-42e5-9ca2-db6244341c48%40googlegroups.com.