Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins email plugin doesn't send email to user who broke the build

Tags:

I've setup Jenkins to send emails only to users who broke the build using email-ext plugin, but I'm getting this error:

Not sending mail to unregistered user [email protected] because your SCM claimed this was associated with a user ID ‘John Smith' which your security realm does not recognize; you may need changes in your SCM plugin

I don't really understand what this error means, is the problem in our SCM, or in the email plugin? The emails are taken from the commit history, should I register them somewhere so Jenkins will start working?

For reference, this is the code around the error message in the plugin's source code:

                    } catch (UsernameNotFoundException x) {                         if (SEND_TO_UNKNOWN_USERS) {                             listener.getLogger().printf("Warning: %s is not a recognized user, but sending mail anyway%n", userAddress);                         } else {                             listener.getLogger().printf("Not sending mail to unregistered user %s because your SCM"                     ........ 

How do I enable SEND_TO_UNKNOWN_USERS?

The error message is also mentioned in this bug report.

like image 721
sashoalm Avatar asked Jul 27 '17 12:07

sashoalm


People also ask

How do I send an email notification if retry build is failed in Jenkins?

Select “Configure”. Select “Add post-build action” and Click “E-Mail Notification”. Enter your recipients mail address and select first option “Send e-mail for every unstable build”. Click “Save” button.

How do I add an email recipient in Jenkins?

Click the 'Advance Settings…' button in the 'Editable Email Notification' box. Click the 'Add Trigger' drop-down and select the 'Always' option and Click the 'Save' button. Go to Email-Notification Jenkins job and click on Build now. Check the Recipient's mail box.

Can Jenkins send email?

Jenkins provide plugins to Send Emails. You just need to install and configure the plugin correctly. You can configure email notifications in your jobs in two ways: Default Email Notifier (Email-Notification)


2 Answers

For version V2.61 or above this can be configured via a radio button.

Go to

Manage Jenkins -> Configure System -> Extended E-mail Notification

and tick the radio button for Allow sending to unregistered users

enter image description here

Edit: If this does not work, see https://stackoverflow.com/a/45353810/492336 for another solution.

like image 111
sha12 Avatar answered Sep 30 '22 19:09

sha12


OK, after some experiments this is what I found out:

Jenkins takes the email part of the committer (not the author). For example for a commit message that looks like that:

Author: John Smith <[email protected]>  2017-07-27 17:15:39 Committer: John Doe <[email protected]>  2017-07-27 17:15:39 Parent: 9c3ff18dda8ca6f7b7ac4ebab4c76d3c85891a33 (commit) Branch: master 

Jenkins will take "committer1", and create a brand new user under People with User ID "committer1" and email "". Unless that user has a password however, it will be considered unregistered so you need to go to Configure for that user and add a password field to it:

enter image description here

So this is one way to fix the error, but you have to do it for every user and in a big team it can be tedious.

like image 23
sashoalm Avatar answered Sep 30 '22 20:09

sashoalm