jenkinsci / jenkinsci/git-plugin

[JENKINS-51218] EMail-Ext does not send email, because or empty recipients

Open
#3,299 19 comments 0 reactions 0 assignees View on GitHub
component:git-plugin component:scm-api-plugin imported-jira-issue priority:critical resolution:unresolved
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

I send my mail via groovy script in a multibranch-pipeline (blue ocean)

```
script
{
def currResult = getResultAsString(currentBuild)
def prevResult = getResultAsString(currentBuild.getPreviousBuild())
if (currResult != "SUCCESS" || prevResult != "SUCCESS")
{
echo 'send mail'
emailext body: '''${SCRIPT, template="my-html.template"}''',
recipientProviders: [[$class: 'DevelopersRecipientProvider'],
[$class: 'CulpritsRecipientProvider'],
[$class: 'UpstreamComitterRecipientProvider'],
],
subject: '[Jenkins]: ${JOB_NAME} ${BUILD_DISPLAY_NAME} - ' + currResult,
mimeType: 'text/html'
}

}

def getResultAsString(build)
{
def result = build?.result
if (result == null) {
result = "SUCCESS"
}
return result;
}

```

When creating a new branch and adding a commit which will fail this build,

jenkins will not send a email, with following message:

```
An attempt to send an e-mail to empty list of recipients, ignored.

```

However, when adding another commit to the same branch, jenkins, will now surprisingly have a commiter email address and can send the email.

So always the first build of a new branch, email-ext will not retrieve a correct email from the commit.

Can you please fix it?

---
Originally reported by zack, imported from: EMail-Ext does not send email, because or empty recipients


  • status: Open
  • priority: Critical
  • component(s): git-plugin, scm-api-plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 6
  • imported: 2025-12-02

Raw content of original issue

I send my mail via groovy script in a multibranch-pipeline (blue ocean)



script 

{
def currResult = getResultAsString(currentBuild)
def prevResult = getResultAsString(currentBuild.getPreviousBuild())
if (currResult != "SUCCESS" || prevResult != "SUCCESS")
{
echo 'send mail'
emailext body: '''${SCRIPT, template="my-html.template"}''',
recipientProviders: [[$class: 'DevelopersRecipientProvider'],
[$class: 'CulpritsRecipientProvider'],
[$class: 'UpstreamComitterRecipientProvider'],
],
subject: '[Jenkins]: ${JOB_NAME} ${BUILD_DISPLAY_NAME} - ' + currResult,
mimeType: 'text/html'
}

}

def getResultAsString(build)
{
def result = build?.result
if (result == null) {
result = "SUCCESS"
}
return result;
}


When creating a new branch and adding a commit which will fail this build,
jenkins will not send a email, with following message:



An attempt to send an e-mail to empty list of recipients, ignored.



However, when adding another commit to the same branch, jenkins, will now surprisingly have a commiter email address and can send the email.
So always the first build of a new branch, email-ext will not retrieve a correct email from the commit.

Can you please fix it?

environment

```
master node on Ubuntu x64

slave node on Windows
```

2 attachments

- [installed_plugins.txt](https://issues.jenkins.io/secure/attachment/42522/installed_plugins.txt)
- [jenkins_changes.jpg](https://issues.jenkins.io/secure/attachment/42564/jenkins_changes.jpg)
> ![jenkins_changes.jpg](https://issues.jenkins.io/secure/attachment/42564/jenkins_changes.jpg)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.