Wednesday, November 29, 2017

How to fix mail settings issue in Jenkins or Hudson

When you are trying to configure automatic mail notification in Jenkins.You need to follow below steps.
  1. Set System Admin e-mail address.
    Manage Jenkins link left side → Goto “Jenkins Location” section → System Admin e-mail Address.
  2. Set Mail server settings.
    Goto email Notification section down → enter below fields.
    SMTP server : smtp.office365.com
    check SMTP authentication checkbox and you will get below options enabled and need to fill as below.
    username(same email ID as above),password,smtp port(587)
  3. Click on apply/save.
To check the above configuration: check the “Test configuration by sending test e-mail” checkbox and provide the email ID in the entry enabled and click on “Test Configuration” button.
If you get any error like “mail client is not authenticated” then you need to enable TLS for Jenkins.
How to do that?
If you are using Jenkins on Linux then:
Open the file /etc/default/jenkins and add below text to it on a new line.
JAVA_ARGS=”-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true”
If it already had a variable with same name then append the value to the same variable inside the quotes.
If you are using Jenkins on Windows then:
You may have Jenkins installed with two options.
1. Jenkins war file running with Tomcat.
2. Jenkins war file running using “java -jar jenkins.war” command with command prompt.
3. Jenkins msi installed locally on the machine and there is a jenkins service installed.
For those people using the 3rd option:
Goto <C:\Program Files\Jenkins\> or <C:\Program Files\Jenkins-OC\>.Or program files (x86) if it is a 64-bit OS.And open the jenkins.xml file and goto the arguments tab and add the value there.
Below is the modified value as in my Jenkins machine:
I have added entry -Dmail.smtp.starttls.enable=true
<executable>%BASE%\jre\bin\java</executable>
  <arguments>-Dmail.smtp.starttls.enable=true -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
  

No comments:

Post a Comment