From 92b752711219e25d80102dc041cd7e69d5308211 Mon Sep 17 00:00:00 2001 From: Ewelina Wilkosz Date: Fri, 24 Mar 2017 13:32:41 +0100 Subject: [PATCH] Fix #153: smtp server configuration in globalconfig (#156) --- dockerizeit/master/globalconfig.groovy | 16 ++++++++++++++++ dockerizeit/master/jenkins.properties | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/dockerizeit/master/globalconfig.groovy b/dockerizeit/master/globalconfig.groovy index 0f1420b..543a5cb 100644 --- a/dockerizeit/master/globalconfig.groovy +++ b/dockerizeit/master/globalconfig.groovy @@ -44,6 +44,22 @@ def desc = inst.getDescriptor("hudson.plugins.git.GitSCM") desc.setGlobalConfigName(properties.global.git.name) desc.setGlobalConfigEmail(properties.global.git.email) +if(properties.global.smtp.enabled) { + println "--> Set E-mail Notification" + if(properties.global.smtp.authentication.enabled) { + File pwdFile = new File(properties.global.smtp.authentication.passwordFile) + if(!pwdFile.exists()) { + println "Smpt password file missing!" + } else { + def emailDesc = inst.getDescriptor(hudson.tasks.Mailer) + emailDesc.setSmtpHost(properties.global.smtp.host) + emailDesc.setSmtpPort(properties.global.smtp.port) + emailDesc.setSmtpAuth(properties.global.smtp.authentication.login, pwdFile.text.trim()) + emailDesc.setReplyToAddress(properties.global.smtp.reply_to_address) + } + } +} + println "--> Set system message " def env = System.getenv() if ( env.containsKey('master_image_version') ) { diff --git a/dockerizeit/master/jenkins.properties b/dockerizeit/master/jenkins.properties index ba8c6c5..edb42e5 100644 --- a/dockerizeit/master/jenkins.properties +++ b/dockerizeit/master/jenkins.properties @@ -70,6 +70,17 @@ global { master_image_name = "${images.masterImageName}" slave_image_name = "${images.slaveImageName}" } + smtp { + enabled = false + port = "25" + host = "1.1.1.1" + reply_to_address = "no-reply@yourcompany.com" + authentication { + enabled = true + login = "jenkins" + passwordFile = "/var/jenkins_home/.ssh/.smtp_password" + } + } } libraries{