Sending email using SMTP (Gmail) from Hudson CI

Have a look in your /etc/init.d/hudson script (you'll need to prefix the edit command with sudo) and you will see a similar java command to the one you listed above. Just add the -Dmail.smtp.starttls.enable="true" paramter to that command and you should be good to go.


I used this post to prepare my enviroment to send email that's was so helpful. For the other hand the best way to put extra parameters in java without change the hudson script is changing the hudson configuration file which define the default values for the system.

In my case i have used CentOS and the location file is /etc/sysconfig/hudson - stop the service first: service hudson stop - sudo vim hudson - Edit the variables that you need in the case of the post:

HUDSON_JAVA_OPTIONS="-Djava.awt.headless='true' -Dmail.smtp.starttls.enable='true'"

Save after edit and start hudson again: service hudson stop

I hope my comments could help


In ubuntu I added this by modifying the default jenkins file in /etc/default to add the JAVA_ARGS option. Then restarted jenkins for the change to take affect. Patch below.

--- /etc/default/jenkins.orig   2011-04-13 13:56:57.651180999 -0700
+++ /etc/default/jenkins        2011-04-13 14:23:38.651181002 -0700
@@ -8,6 +8,7 @@

 # arguments to pass to java
 #JAVA_ARGS="-Xmx256m"
+JAVA_ARGS='-Dmail.smtp.starttls.enable="true"'

 PIDFILE=/var/run/jenkins/jenkins.pid