Emails Not Getting sent with SMTP Server Configured in Gerrit v3.2 - email

I have edited gerrits config file with the required SMTP details:
[sendemail]
enable = true
smtpServer = smtp.server.com
smtpServerPort = 25
But the thing is, the details somehow don't work upon gerrit but the same values do work upon Jenkins.
There really isnt helpful documentation out there wrt to Gerrit. I even tried to configure the server side of settings for projects config file with:
[access]
inheritFrom = All-Projects
[submit]
action = inherit
[access "refs/*"]
owner = blah blah blah
[notify "Administrators"]
email = blah#blahblahblah.com
I tried looking into error logs as well but NOTHING. Any pointers would be really helpful for me.

Issue Resolved
The configuration at the gerrit.conf side is just the server side of it.
For the client side, go to Settings -> Notifications.
Set notifications for
-> Project Name: <whichever project you have access to>
-> Branch: master
or any other branch of your choice.
-> Save Changes
Once you have configured the notifications, the subscribed events would be sent to you in the form of emails via Gerrit.

Related

Notification for ’A pull request is created or updated‘ is not working when application-tier is Simplified-Chinese

- Version:
azure devops Dev17.M153.5
sql server 15.0.2000
- Reproducible Steps:
Install the azure devops 2019 1.1
Configure the application-tier as Simplified-Chinese
Finish the installation
Create the team notification for ’A pull request is created or updated‘
Check the mailbox
Information:
PR notification email was not received
Follow the instruction and we got the following message:
"messages":[{"level":1,"time":"11:23:40.2682787","message":
"设置电子邮件格式时出错。将改为发送一条错误消息。
MustacheExpressionInvalidException:对于表达式“stringFormat“在 {0} 中打开”event.secondaryToolName”找不到帮助程序“stringFormat“在”
#MustacheTemplatedExpression..ctor:0
#MustacheExpression.Parse:0
#ContributedTemplateServiceBase`1.ParseFieldToken:0
#ContributedTemplateServiceBase`1.ParseFieldToken:0
#ContributedTemplateServiceBase`1.ParseFieldToken:0
#ContributedTemplateServiceBase`1.ParseFieldToken:0
"
- We have tried :
Double-check the Why am I not getting an email ---- No issue is against the rules in the guidance
Try another notification type, such as "Work item is created" or "A build completes" ---- We can receive the related email
Remove the application-tier which has been initialized as Simplified-Chinese, and re-initialize the new application-tier as English-----The expected PR notification email was RECEIVED !!!
In order to narrow down the issue, you could try the following items:
Check whether you have the latest patch installed: https://learn.microsoft.com/en-us/azure/devops/server/release-notes/azuredevops2019u1?view=azure-devops
If you configure the application-tier as Simplified-Chinese again, would you be able to see the issue agine?
Check in other team projects to see whether you can reproduce this issue.
Create a new team project collection, and create a new team project in it, to see whether you can reproduce this issue.
Check the event log in Event Viewer, to see whether there is useful information.

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

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 user#example.com 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.
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
Edit: If this does not work, see https://stackoverflow.com/a/45353810/492336 for another solution.
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 <author1#example1.com> 2017-07-27 17:15:39
Committer: John Doe <committer1#example2.com> 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:
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.
Put the line bellow in your jenkins startup script
-Dhudson.tasks.MailSender.SEND_TO_UNKNOWN_USERS=true
The newest Jenkins security directive only allow sending mail to registered user. The line above bypass this configuration.
Given jenkins takes the first part of the email address and creates a user, I made my team have their jenkins user name be the first part of their email address. This removed any overhead of having to maintain two separate users.

Gerrit not sending emails

I have set up a Gerrit server and trying to make it send emails (for all events). But for some reason Gerrit doesn't send any emails. error_logs shows absolutely no data, that means it is not even trying to send emails.
Here is relevant part of my project.config for All-Projects:
[notify "demo"]
email = me#company.com
type = all
Here is my gerrit.config:
[gerrit]
basePath = git
canonicalWebUrl = http://hostname:8443/
[database]
type = h2
database = db/ReviewDB
connectionPool = true
poolLimit = 128
[index]
type = LUCENE
[auth]
type = LDAP
[ldap]
poolDebug = all
server = ldap://nod.company.com
accountBase = cn=users,dc=company,dc=com
accountEmailAddress = mail
referral = follow
[sendemail]
smtpServer = relay.company.com
smtpServerPort = 25
smtpUser = my_username
[container]
user = gerrit2
javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre
heapLimit = 2g
[sshd]
listenAddress = *:29419
maxConnectionPerUser = 256
[automerge]
botEmail = me#company.com
[download]
scheme = ssh
[httpd]
listenUrl = http://*:8443/
maxThreads = 128
[cache]
directory = cache
[gitweb]
cgi = /usr/share/gitweb/gitweb.cgi
Environment: Ubuntu 14.04 and Gerrit 2.11.6.
I have tried to send emails from command line on this server and that works just fine.
All of my individual projects on Gerrit inherit access rights from All-Projects. I even tried adding the email section to each individual project but that didn't help either.
My colleague, who has his own Gerrit server that is able to send emails, looked into my issue and couldn't figure out what's wrong with my server. We both have same Linux version, Gerrit version, gerrit.config and project.config.
Ok, found the issues and fixed them. I had two issues, sharing for user reference.
I installed sendmail utility when logged in as a user other than smtpUser account mentioned in gerrit.config. After that I forgot to add the sendmail utility to /opt and hence the smtpUser's account from gerrit.config was not able to access the sendmail utility. Once I shared the sendmail utility with all user accounts, gerrit started sending emails.
To summarize, make sure the user account mentioned under smtpUser has sendmail available to it. Thanks everyone for your time.
gerrit wont send the email ONLY to the user that is also the smtpUser in gerrit.config. I was testing it by sending emails to only me, and hence it didnt work. I had to change to project config to add an email address other than my own email account.
I dont know if this is a gerrit bug or a gerrit feature. If a feature then not sure what is the use case for this !!
I hope this info helps other guys out there.
I had this problem after a recent Gerrit update (from 2.15 -> 3.2).
I checked the postfix logs in /var/log/maillog and they clearly showed that after the machine was rebooted following the Gerrit update no more mails arrived here.
Looking further into <gerrit-path>/logs/error_log (I had to look in rollated files) showed me that there seemed to be a problem with our mail template and also gave me the path to the offending file.
We previously used a custom mail template from https://gist.github.com/orgads/d8a61a1c10efeb7a4fafbcb6374167c3, the format of which seems to no longer be valid. I replaced this with the .soy.example file provided by Gerrit which fixed the issue.
For me, since I was trying to test emails by getting them to send to my own email, I had to go to settings (Gerrit 2.15.17 BTW), then preferences, under email notifications, select "every comment" in the dropdown menu.

GitHub Windows client behind proxy

I'm trying to get the GitHub client for Windows working. I am on a corporate Win 7 x64 computer behind a corporate proxy and firewall. Following various other posts and experimenting with multiple combinations of environment variables and config variables I have found the only way to get cloning and push updates to work is by using the HTTPS_PROXY environment variable, including my full corporate domain user ID and password.
This is unacceptable from a security standpoint. Is there any other way to get this to work?
Additional notes:
The following worked:
Add an environment variable called HTTPS_PROXY with the value http://[domain]\[userid]:[password]#someproxy.mycorp.com:8080
The following did not work:
Omitting user id and password from HTTPS_PROXY variable
Using an environment variable called HTTP_PROXY (no S)
Adding the http.proxy variable to the global config file (.gitconfig)
Adding the https.proxy variable to the global config file
In all cases, the GitHub client still does not recognize the proxy: The content of the file TheLog.txt always shows the following on startup:
[time]|INFO|thread:4|GitHub.Helpers.StartupLogger|Proxy information: (None)
[time]|INFO|thread:4|GitHub.Helpers.StartupLogger|Couldn't fetch creds for proxy
And is followed by the output of several failed proxy authentication attempts, all of which indicate "Credentials are missing."
Add these entries to your '.gitconfig' file in your user directory (go to %USERPROFILE%):
[http]
proxy = http://<proxy address>:<proxy port>
[https]
proxy = https://<proxy address>:<proxy port>
And if you don't want to store your password in plaintext, I would use a local proxy forwarder like CNTLM which allows you to direct all traffic through it and can store the passwords hashed.
Unlike the original question, if you don't care if your password is in plain text add these:
[http]
proxy = http://<username>:<password>#<proxy address>:<proxy port>
[https]
proxy = https://<username>:<password>#<proxy address>:<proxy port>
Tried everything of above - and didn't succeed, only thing that helped me is CNTLM - http://cntlm.sourceforge.net/.
Install it and run cntlm -H, than authenticate to corp proxy, edit cntlm.ini file with the output of cntlm, restart the windows service. Update .gitconfig with:
[https] proxy = localhost:3128
[http] proxy = localhost:3128
Now cntlm will do all the authentication, and you'll be able to use GitHub(and Dropbox, btw) behind the corp proxy. At least until next password change :) (than do cntlm -H stuff again)
I was able to make GitHub Shell to work with our corporate proxy. I'm starting GitHub Shell and execute following command:
export http_proxy=http://<username>:<password>#<corporate proxy>:3128
I would really like to make GUI to work too. But I don't want to set Windows global environment variable which contains my corporate credential information.
Strangely GitHub GUI Client is able to connect to GitHub for user authentication, but only problem is with cloning, pulling and pushing projects from and into GitHub. It seems like the problem is with git implementation. I was able to configure git to run through our proxy without putting my credentials in the git global settings and it was asking for my credentials while performing pull or push requests. But that was working only in Git Shell.
If you’re using GitHub for Windows in a corporate, chances are high that you’re behind a big bad Corporate Firewall/Proxy. GitHub for Windows doesn’t yet have the proxy parameters in its GUI for setting Options.
To configure GitHub for Windows to use your corporate proxy, edit the .gitconfig file typically found at C:\Users\.gitconfig or C:\Documents & Settings\.gitconfig
Close GitHub for Windows; In .gitconfig, just add
[https]
proxy = proxy.yourcompany.com:port
I've also run into this issue, and tried to dig into it a bit as well (disassembled the client).
The piece of code that generates the log messages we're seeing is as follows:
private static void LogProxyServerConfiguration()
{
WebProxy defaultProxy = WebProxy.GetDefaultProxy();
string str = defaultProxy.Address != (Uri)null ? defaultProxy.Address.ToString() : "(None)";
StartupLogger.log.Info((IFormatProvider)CultureInfo.InvariantCulture, "Proxy information: {0}", str);
try
{
if (defaultProxy.Credentials == null)
{
StartupLogger.log.Info((IFormatProvider)CultureInfo.InvariantCulture, "Couldn't fetch creds for proxy", new object[0]);
}
else
{
NetworkCredential credential = defaultProxy.Credentials.GetCredential(GitHubClient.GitHubDotComUri, "Basic");
StartupLogger.log.Info((IFormatProvider)CultureInfo.InvariantCulture, "Proxy is authenticated: {0}", credential != null && !string.IsNullOrWhiteSpace(credential.UserName));
}
}
catch (Exception ex)
{
StartupLogger.log.InfoException("Couldn't fetch creds for proxy", ex);
}
}
So this block only logs the proxy information that's setup in IE. The log message appears to have no bearing on what we have setup in the config files or environmental variables.
i dont know about your firewall, but my campus use proxy
do you use any git gui? EDIT : just noticed that you're using github client for windows
i am using tortoisegit and its very easy to set the proxy. Just right click anywhere, tortoisegit>network, enable proxy server and set server address, username, and password. done
as far as i remember, tortoisegit will also works out-of-the-box with github.
Here is the way to set proxy in github
git config --global http.proxy http://<username>:<pass>#<ip>:<port>
git config --global https.proxy http://<username>:<pass>#<ip>:<port>
Here in my college we don't have username and password, so if our college
ip is 172.16.10.10 and
port is 8080
git config --global http.proxy http://172.16.10.10:8080
git config --global https.proxy http://172.16.10.10:8080
P.S -> I would recommend using this method to set proxy as things will fall into place as you will learn further
Source
I found this blog to be useful. It describes ntlmaps proxy. It's probably less secure, but worked smoothly. I couldn't get cntlm working.
For us, the solution involved two different things. First, as described in Sogger's answer, you need to add the entries to your .gitconfig file, located in %USERPROFILE%.
[http]
proxy = http://<proxy address>:<proxy port>
[https]
proxy = https://<proxy address>:<proxy port>
Second, (and this was the missing piece for us,) you need to configure an exception on the proxy server to allow non-authenticated proxy traffic to *.github.com
In iPrism, it looks like this:
The problem is not so much the proxy, but the authentication. Bypassing the authentication requirement allows the needed communication to clone and work with projects using the GitHub desktop client.
Also note that this approach did not require storing proxy credentials in the .gitconfig file.
In case you need to force Git or GitHub client to bypass the proxy (use the direct connection), just set the proxy URI in the .gitconfig to an empty string. You'll probably have to edit the file manually, I didn't manage to persuade the git config command to set the value of a configuration directive to an empty string (tried git config --global http.proxy "").
So just add the following lines to the ~/.gitconfig:
[http]
proxy = ""
[https]
proxy = ""

"RA layer request failed" error with Subclipse, no errors with web browser

I'm using STS 2.8.1 (I think it's based on Eclipse Indigo) with Subclipse 1.6.18.
I'm trying to check some code out from a repository, but when I add the repository location, I get the following error:
RA layer request failed
svn: Server sent unexpected return value (503 Service Unavailable) in response to OPTIONS request for 'http://a.b.com:18080/svn/myproject'
The thing is, if I try to access that repository from a web browser (e.g. Chrome or IE), I'm allowed to access it. It asks for my username and password, and after I enter them, I can see the project tree.
Does anyone know why I can access from the web browser but not from STS?
The proxy settings are configured correctly for Subclipse (and I can access other repositories from STS, but not that one).
This is usually due to an SVN setting (c:\Documents and Settings\_username_\Application Data\Subversion\servers or ~/.subversion/servers) overriding an Eclipse setting.
Or one of those settings could have the wrong password for the proxy.
However, the OP Neets reports:
I'm able to connect to other repository locations (so the proxy password is correct)
I solved it, adding the corresponding exception in the servers file, like this:
http-proxy-exceptions = exception.com
That is compliant with what describes the openDNS article Configuring Subversion to Use a Proxy Server:
http-proxy-exceptions
This specifies a set of repository addresses for which you don't need to access a proxy server. For example, if you have a repository on your local LAN, then you probably won't need a proxy to access it.
This should be a comma-delimited list of servers, and you can use an asterisk as a wildcard.
If all of the repositories that you will access require you to use a proxy server, then you can leave this out.
The following shows a sample configuration that will use a proxy server to access all servers outside of the example.com domain:
[global]
http-proxy-exceptions = *.example.com
http-proxy-host = proxy.example.com
http-proxy-port = 8080
http-proxy-username = myuserid
http-proxy-password = mypassword