Fix SMTP configuration
Fix the issue that ExtendedEmailPublisherDescriptor has
no method getSmtpAuthUsername.
Change-Id: I2d981673ab3226c9ae4600542642c3297579c08b
diff --git a/_states/jenkins_smtp.py b/_states/jenkins_smtp.py
index 45f0244..b03b3a7 100644
--- a/_states/jenkins_smtp.py
+++ b/_states/jenkins_smtp.py
@@ -3,12 +3,11 @@
logger = logging.getLogger(__name__)
set_smtp_groovy = """\
-def result = ""
+def result = "FAILED"
for(desc in [Jenkins.getInstance().getDescriptor("hudson.plugins.emailext.ExtendedEmailPublisher"),Jenkins.getInstance().getDescriptor("hudson.tasks.Mailer")]){
if(desc.getSmtpServer().equals("${host}") &&
- ((desc instanceof hudson.plugins.emailext.ExtendedEmailPublisherDescriptor && desc.getSmtpAuthUsername().equals("${username}")) ||
- (desc instanceof hudson.tasks.Mailer$DescriptorImpl && desc.getSmtpAuthUserName().equals("${username}"))) &&
- desc.getSmtpAuthPassword().toString().equals("${password}") &&
+ (desc instanceof hudson.tasks.Mailer$DescriptorImpl ? desc.getSmtpAuthUserName() : desc.getSmtpUsername()) == "${username}" &&
+ (desc instanceof hudson.tasks.Mailer$DescriptorImpl ? desc.getSmtpAuthPassword() : desc.getSmtpPassword().toString()) == "${password}" &&
desc.getSmtpPort().equals("${port}") &&
desc.getUseSsl() == ${ssl} &&
desc.getCharset().equals("${charset}") &&