Pipeline: Doesn't always get commit authors in emailextrecipients

1,816 views
Skip to first unread message

Sverre Moe

unread,
Sep 2, 2016, 4:36:38 AM9/2/16
to Jenkins Users
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: "donot...@company.com", subject: SUBJECT, body: CONTENT
   
} else {
        mail to
: repositoryOwners, bcc: "devops", replyTo: "donot...@company.com", subject: SUBJECT, body: CONTENT
   
}
}

Slide

unread,
Sep 2, 2016, 10:13:03 AM9/2/16
to Jenkins Users
mail is using the mailer plugin, if you want to use email-ext, you need to use emailext (see https://jenkins.io/doc/pipeline/steps/email-ext/).

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f19567ce-1322-40ee-b9e3-822073762bc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted
Message has been deleted
Message has been deleted

Sverre Moe

unread,
Sep 5, 2016, 2:16:12 AM9/5/16
to Jenkins Users
I followed the Pipeline examples for the email-ext plugin:
There are 3 examples how to use emailextrecipients

Problem is only mail allows me to set the cc and bcc.

Sverre Moe

unread,
Sep 5, 2016, 2:40:37 AM9/5/16
to Jenkins Users
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.

Sverre Moe

unread,
Sep 5, 2016, 2:45:01 AM9/5/16
to Jenkins Users
It looks like email-ext has support for CC and BCC
However it is not present in the Pipeline syntax.

Sverre Moe

unread,
Sep 5, 2016, 3:16:36 AM9/5/16
to Jenkins Users
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.

Sverre Moe

unread,
Sep 5, 2016, 3:46:43 AM9/5/16
to Jenkins Users
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] emailext
Job 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.

Slide

unread,
Sep 6, 2016, 1:07:42 PM9/6/16
to Jenkins Users
You can set cc and bcc in emailext using prefixes cc:som...@something.com, bcc:someo...@something.com

On Tue, Sep 6, 2016 at 9:16 AM Sverre Moe <sverr...@gmail.com> wrote:
I followed the Pipeline examples for the email-ext plugin:
There are 3 examples how to use emailextrecipients

Problem is only mail allows me to set the cc and bcc.
Message has been deleted

Sverre Moe

unread,
Sep 9, 2016, 2:25:12 AM9/9/16
to Jenkins Users
In what parameter, to or recipientProviders?


tirsdag 6. september 2016 19.07.42 UTC+2 skrev slide følgende:
You can set cc and bcc in emailext using prefixes cc:som...@something.com, bcc:som...@something.com


On another matter: Not sure why, Every time I try to reply on this discussion, the post gets deleted. 

Slide

unread,
Sep 9, 2016, 8:44:33 AM9/9/16
to jenkins...@googlegroups.com
On Thu, Sep 8, 2016 at 11:25 PM Sverre Moe <sverr...@gmail.com> wrote:
In what parameter, to or recipientProviders?



In the "to" parameter. The recipient providers always use the "to" and don't provide a way to do cc or bcc.

 
tirsdag 6. september 2016 19.07.42 UTC+2 skrev slide følgende:
You can set cc and bcc in emailext using prefixes cc:som...@something.com, bcc:som...@something.com


On another matter: Not sure why, Every time I try to reply on this discussion, the post gets deleted.

Are you a member of the google group? If not, perhaps some moderating is happening.
 
 

--
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-use...@googlegroups.com.

Sverre Moe

unread,
Sep 9, 2016, 9:07:00 AM9/9/16
to Jenkins Users
fredag 9. september 2016 14.44.33 UTC+2 skrev slide følgende:

On Thu, Sep 8, 2016 at 11:25 PM Sverre Moe <sverr...@gmail.com> wrote:
In what parameter, to or recipientProviders?



In the "to" parameter. The recipient providers always use the "to" and don't provide a way to do cc or bcc.

Ok. Shall try it. 


tirsdag 6. september 2016 19.07.42 UTC+2 skrev slide følgende:
You can set cc and bcc in emailext using prefixes cc:som...@something.com, bcc:som...@something.com


On another matter: Not sure why, Every time I try to reply on this discussion, the post gets deleted.

Are you a member of the google group? If not, perhaps some moderating is happening.
 
 
Must be some moderating. I am a member of the group. Never had any trouble before.

 

Sverre Moe

unread,
Sep 9, 2016, 9:15:16 AM9/9/16
to Jenkins Users
Anyhow. Why does something return nothing?

final def RECIPIENTS = emailextrecipients([
       
[$class: 'DevelopersRecipientProvider'],
       
[$class: 'CulpritsRecipientProvider'],

       
[$class: 'UpstreamComitterRecipientProvider'],
       
[$class: 'FirstFailingBuildSuspectsRecipientProvider'],
       
[$class: 'FailingTestSuspectsRecipientProvider']
   
])

node("master") {
    emailext body
: CONTENT, recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider'], [$class: 'UpstreamComitterRecipientProvider'], [$class: 'FirstFailingBuildSuspectsRecipientProvider'], [$class: 'FailingTestSuspectsRecipientProvider']], subject: SUBJECT, to: "cc:${CC},bcc:${BCC}"
}

Could anyone confirm that emailext needs access to the source code git repository in the workspace?

Perhaps I should include ALL the recipient providers, just in case.

What I want is to notify the commit authors of failed build. Using only the 3 first recipient providers, something recipients are empty.
Reply all
Reply to author
Forward
0 new messages