Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48756

SMTP settings get lost after first email notification

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • email-ext-plugin
    • None
    • email-ext-plugin 2.61
      Jenkins 2.89.2
      Docker (jenkins/jenkins:lts)

      Hello,

      I have a strange issue with the email notification plugin. We are setting up Jenkins within a Docker container using the scripting configuration. One of the settings is the email server as follows:

      def desc = jenkins.getDescriptor("hudson.plugins.emailext.ExtendedEmailPublisher");
      desc.setSmtpServer("smtp2.local");
      desc.setDefaultSuffix("@suffix.com");
      desc.save();

      After the Jenkins is configured, everything looks good. The server and suffix are configured and visible in the system settings.

      If the first job wants to send a notification, the settings get lost and the email as well.
      Does anyone have the same/similar issue?

      Best regards,
      Dennis

          [JENKINS-48756] SMTP settings get lost after first email notification

          Having never done this myself Im not sure. If you look at the config files just after creation are the settings there?

          David van Laatum added a comment - Having never done this myself Im not sure. If you look at the config files just after creation are the settings there?

          Dennis Lickay added a comment -

          Hello David,

          the weird thing is, that this issue is only present after you try to send the first email notification. This action somehow clears the email configuration entry.
          If you configure it then using the web front-end and store the config again, it works fine without further issues.

          Configuration after Jenkins started

          {{<?xml version='1.0' encoding='UTF-8'?>
          <hudson.plugins.emailext.ExtendedEmailPublisherDescriptor plugin="email-ext@2.61">
          <defaultSuffix>@suffix.com</defaultSuffix>
          <smtpHost>smtp2.local</smtpHost>
          <useSsl>false</useSsl>
          <defaultSubject>$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!</defaultSubject>
          <defaultBody>$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:

          Check console output at $BUILD_URL to view the results.</defaultBody>
          <defaultPresendScript></defaultPresendScript>
          <defaultPostsendScript></defaultPostsendScript>
          <defaultClasspath/>
          <defaultTriggerIds/>
          <emergencyReroute></emergencyReroute>
          <maxAttachmentSize>-1</maxAttachmentSize>
          <recipientList></recipientList>
          <defaultReplyTo></defaultReplyTo>
          <excludedCommitters></excludedCommitters>
          <overrideGlobalSettings>false</overrideGlobalSettings>
          <precedenceBulk>false</precedenceBulk>
          <debugMode>false</debugMode>
          <requireAdminForTemplateTesting>false</requireAdminForTemplateTesting>
          <enableWatching>false</enableWatching>
          <enableAllowUnregistered>false</enableAllowUnregistered>
          </hudson.plugins.emailext.ExtendedEmailPublisherDescriptor>}}

          Configuration after the first notification

          {{<?xml version='1.0' encoding='UTF-8'?>
          <hudson.plugins.emailext.ExtendedEmailPublisherDescriptor plugin="email-ext@2.61">
          <useSsl>false</useSsl>
          <charset>UTF-8</charset>
          <defaultSubject>$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!</defaultSubject>
          <defaultBody>$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:

          Check console output at $BUILD_URL to view the results.</defaultBody>
          <defaultPresendScript></defaultPresendScript>
          <defaultPostsendScript></defaultPostsendScript>
          <defaultClasspath/>
          <defaultTriggerIds>
          <string>hudson.plugins.emailext.plugins.trigger.FailureTrigger</string>
          </defaultTriggerIds>
          <emergencyReroute></emergencyReroute>
          <maxAttachmentSize>-1</maxAttachmentSize>
          <recipientList></recipientList>
          <excludedCommitters></excludedCommitters>
          <overrideGlobalSettings>true</overrideGlobalSettings>
          <precedenceBulk>false</precedenceBulk>
          <debugMode>false</debugMode>
          <requireAdminForTemplateTesting>false</requireAdminForTemplateTesting>
          <enableWatching>false</enableWatching>
          <enableAllowUnregistered>false</enableAllowUnregistered>
          </hudson.plugins.emailext.ExtendedEmailPublisherDescriptor>}}

          Dennis Lickay added a comment - Hello David, the weird thing is, that this issue is only present after you try to send the first email notification. This action somehow clears the email configuration entry. If you configure it then using the web front-end and store the config again, it works fine without further issues. Configuration after Jenkins started {{<?xml version='1.0' encoding='UTF-8'?> <hudson.plugins.emailext.ExtendedEmailPublisherDescriptor plugin="email-ext@2.61"> <defaultSuffix>@suffix.com</defaultSuffix> <smtpHost>smtp2.local</smtpHost> <useSsl>false</useSsl> <defaultSubject>$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!</defaultSubject> <defaultBody>$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results.</defaultBody> <defaultPresendScript></defaultPresendScript> <defaultPostsendScript></defaultPostsendScript> <defaultClasspath/> <defaultTriggerIds/> <emergencyReroute></emergencyReroute> <maxAttachmentSize>-1</maxAttachmentSize> <recipientList></recipientList> <defaultReplyTo></defaultReplyTo> <excludedCommitters></excludedCommitters> <overrideGlobalSettings>false</overrideGlobalSettings> <precedenceBulk>false</precedenceBulk> <debugMode>false</debugMode> <requireAdminForTemplateTesting>false</requireAdminForTemplateTesting> <enableWatching>false</enableWatching> <enableAllowUnregistered>false</enableAllowUnregistered> </hudson.plugins.emailext.ExtendedEmailPublisherDescriptor>}} Configuration after the first notification {{<?xml version='1.0' encoding='UTF-8'?> <hudson.plugins.emailext.ExtendedEmailPublisherDescriptor plugin="email-ext@2.61"> <useSsl>false</useSsl> <charset>UTF-8</charset> <defaultSubject>$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!</defaultSubject> <defaultBody>$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results.</defaultBody> <defaultPresendScript></defaultPresendScript> <defaultPostsendScript></defaultPostsendScript> <defaultClasspath/> <defaultTriggerIds> <string>hudson.plugins.emailext.plugins.trigger.FailureTrigger</string> </defaultTriggerIds> <emergencyReroute></emergencyReroute> <maxAttachmentSize>-1</maxAttachmentSize> <recipientList></recipientList> <excludedCommitters></excludedCommitters> <overrideGlobalSettings>true</overrideGlobalSettings> <precedenceBulk>false</precedenceBulk> <debugMode>false</debugMode> <requireAdminForTemplateTesting>false</requireAdminForTemplateTesting> <enableWatching>false</enableWatching> <enableAllowUnregistered>false</enableAllowUnregistered> </hudson.plugins.emailext.ExtendedEmailPublisherDescriptor>}}

          Very weird, if you restart the container after initial creation do the settings stay then?

          David van Laatum added a comment - Very weird, if you restart the container after initial creation do the settings stay then?

          Dennis Lickay added a comment -

          Yes, I don't think the issue is related to Docker itself. The first attempt to send an email after the very first Jenkins start leads to the behaviour described above.

          Dennis Lickay added a comment - Yes, I don't think the issue is related to Docker itself. The first attempt to send an email after the very first Jenkins start leads to the behaviour described above.

          Alex Earl added a comment -

          In the first set of XML (before the first notification is sent), overrideGlobalSettings is false, this means that email-ext will try and upgrade from the settings for the mailer plugin, which if they are empty will overwrite your settings with empty settings. You need to see if you can set the overrideGlobalSettings, or set the same settings for the mailer plugin during container setup so this does not occur.

          Alex Earl added a comment - In the first set of XML (before the first notification is sent), overrideGlobalSettings is false, this means that email-ext will try and upgrade from the settings for the mailer plugin, which if they are empty will overwrite your settings with empty settings. You need to see if you can set the overrideGlobalSettings, or set the same settings for the mailer plugin during container setup so this does not occur.

          Dennis Lickay added a comment -

          slide_o_mix Thank you! Seem to resolve the problem.

          Dennis Lickay added a comment - slide_o_mix Thank you! Seem to resolve the problem.

            davidvanlaatum David van Laatum
            dlickay Dennis Lickay
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: