I tried to test that theory by getting emailextrecipients right after 
checkout scm within my Checkout stage.
However it gives me no recipients.

[Pipeline] emailextrecipients[Pipeline] emailextJob type does not allow token 
replacement.
Job type does not allow token replacement.
Job type does not allow token replacement.
An attempt to send an e-mail to empty list of recipients, ignored.


Also seems it has some problems with ${PARAM} within the variables for 
SUBJECT and BODY.

mandag 5. september 2016 09.16.36 UTC+2 skrev Sverre Moe følgende:
>
> Must run emailext within a heavyweight executor.
> node {
>     emailext subject: SUBJECT, body: CONTENT, cc: "devops", 
> recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 
> 'DevelopersRecipientProvider'], [$class: 
> 'UpstreamComitterRecipientProvider']]
> }
>
> While the standard mail can run on a flyweight executor:
>
> I have a theory:
> In order to get a list of recipients email-ext needs the git repository 
> available on a heavyweight executor in order to get developers, culprits 
> and commiters from each commit in the build.
>
> That is probably why emailextrecipients does not give me any recipients 
> running on a flyweight executor.
>
> mandag 5. september 2016 08.45.01 UTC+2 skrev Sverre Moe følgende:
>>
>> It looks like email-ext has support for CC and BCC
>>
>> https://github.com/jenkinsci/email-ext-plugin/commit/4aacabf9b9fa9be326ebc362519e2f5d1bbb43fb
>> However it is not present in the Pipeline syntax.
>>
>> mandag 5. september 2016 08.40.37 UTC+2 skrev Sverre Moe følgende:
>>>
>>> It would seem that the step emailextrecipients would give a list of 
>>> recipients so using Mailer should work.
>>>
>>> final def RECIPIENTS = emailextrecipients([
>>>     [$class: 'DevelopersRecipientProvider'],
>>>     [$class: 'CulpritsRecipientProvider'],
>>>     [$class: 'UpstreamComitterRecipientProvider']
>>> ])
>>>
>>> step([$class: 'Mailer', notifyEveryUnstableBuild: true,  recipients: 
>>> RECIPIENTS])
>>>
>>> emailext body: CONTENT, recipientProviders: [[$class: 
>>> 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider'], [
>>> $class: 'UpstreamComitterRecipientProvider']], subject: SUBJECT
>>>
>>> mail to: RECIPIENTS, cc: repositoryOwners, bcc: "devops", subject: 
>>> SUBJECT, body: CONTENT
>>>
>>>
>>> However I do not always get anything out of emailextrecipients.
>>>
>>> mandag 5. september 2016 08.16.12 UTC+2 skrev Sverre Moe følgende:
>>>>
>>>> I followed the Pipeline examples for the email-ext plugin:
>>>>
>>>> https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin#Email-extplugin-PipelineExamples
>>>> There are 3 examples how to use emailextrecipients
>>>>
>>>> Problem is only mail allows me to set the cc and bcc.
>>>>
>>>> fredag 2. september 2016 10.36.38 UTC+2 skrev Sverre Moe følgende:
>>>>>
>>>>> There seems to be a lottery of some sort what I get 
>>>>> from emailextrecipients
>>>>>
>>>>> I expect to get the authors from the commits it is building, but most 
>>>>> of the times emailextrecipients gives me nothing.
>>>>>
>>>>> /**
>>>>>  * Notify developers of failed build
>>>>>  */
>>>>> void notifyFailedBuild() {
>>>>>     final def projectName = packageInfo.getProjectName()
>>>>>     final def repositoryOwners = getRepositoryOwners(projectName)
>>>>>
>>>>>     final def RECIPIENTS = emailextrecipients([
>>>>>         [$class: 'DevelopersRecipientProvider'],
>>>>>         [$class: 'CulpritsRecipientProvider'],
>>>>>         [$class: 'UpstreamComitterRecipientProvider']
>>>>>     ])
>>>>>
>>>>>     final def SUBJECT = "${projectName} ${env.BRANCH_NAME} - Build 
>>>>> #${env.BUILD_NUMBER} - FAILED!"
>>>>>     final def CONTENT = "Check console output at ${env.BUILD_URL} to 
>>>>> view the results."
>>>>>
>>>>>     if (RECIPIENTS != null && !RECIPIENTS.isEmpty()) {
>>>>>         mail to: RECIPIENTS, cc: repositoryOwners, bcc: "devops", 
>>>>> replyTo: "donotre...@company.com", subject: SUBJECT, body: CONTENT
>>>>>     } else {
>>>>>         mail to: repositoryOwners, bcc: "devops", replyTo: "
>>>>> donotre...@company.com", subject: SUBJECT, body: CONTENT
>>>>>     }
>>>>> }
>>>>>
>>>>>

-- 
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/6d79e6c5-76ab-4fb8-b44f-0024324a6809%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to