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

From address can't be changed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: email-ext-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.249.1. Email ext plugin 2.77.
    • Similar Issues:
    • Released As:
      2.78

      Description

      To send mail via smtp.office365.com, a correct "from" address is required. If you don't set "from" in the pipleine step, the plugin should use the admin email. The first time the plugin is used, this address is fixed and can't be changed in the UI. 

      I believe the problem is with this code in ExtendedEmailPublisherDescriptor:

       

      public String getAdminAddress() {
              JenkinsLocationConfiguration config = JenkinsLocationConfiguration.get();
              if(config != null) {
                  if(StringUtils.isBlank(mailAccount.getAddress())) {
                      mailAccount.setAddress(config.getAdminAddress());
                  }
              }
              return mailAccount.getAddress();
          }
      
      

      Once an address has been recorded it can never change, even if you change the admin address. In my case it was the "nobody" address.

       

      The address is recorded in Jenkins home directory, file .jenkins/hudson.plugins.emailext.ExtendedEmailPublisher.xml. A viable workaround is to edit the file and correct the address element. Example:

      <address>address not configured yet &lt;nobody@nowhere&gt;</address>
      ->
      <address>correct@adress</address>

      Then restart Jenkins.

        Attachments

          Issue Links

            Activity

            Hide
            basil Basil Crow added a comment -

            I wrote a simple test and determined through bisection that this was working as of email-ext 2.71. The regression occurred in email-ext 2.72 as part of commit 1160d45.

            Show
            basil Basil Crow added a comment - I wrote a simple test and determined through bisection that this was working as of email-ext 2.71. The regression occurred in email-ext 2.72 as part of commit 1160d45 .
            Hide
            basil Basil Crow added a comment -

            The specific lines of commit 1160d45 that introduced the regression are the following lines:

            @@ -226,15 +236,20 @@ public final class ExtendedEmailPublisherDescriptor extends BuildStepDescriptor<
                 }
             
                 public String getAdminAddress() {
            -        JenkinsLocationConfiguration configuration = JenkinsLocationConfiguration.get();
            -        assert configuration != null;
            -        return configuration.getAdminAddress();
            +        JenkinsLocationConfiguration config = JenkinsLocationConfiguration.get();
            +        if(config != null) {
            +            if(StringUtils.isBlank(mailAccount.getAddress())) {
            +                mailAccount.setAddress(config.getAdminAddress());
            +            }
            +        }
            +        return mailAccount.getAddress();
                 }
            

            Reverting this hunk at commit 1160d45 fixes the problem, though I am not sure if it breaks anything CasC-related.

            Show
            basil Basil Crow added a comment - The specific lines of commit 1160d45 that introduced the regression are the following lines: @@ -226,15 +236,20 @@ public final class ExtendedEmailPublisherDescriptor extends BuildStepDescriptor< } public String getAdminAddress() { - JenkinsLocationConfiguration configuration = JenkinsLocationConfiguration.get(); - assert configuration != null ; - return configuration.getAdminAddress(); + JenkinsLocationConfiguration config = JenkinsLocationConfiguration.get(); + if (config != null ) { + if (StringUtils.isBlank(mailAccount.getAddress())) { + mailAccount.setAddress(config.getAdminAddress()); + } + } + return mailAccount.getAddress(); } Reverting this hunk at commit 1160d45 fixes the problem, though I am not sure if it breaks anything CasC-related.
            Hide
            basil Basil Crow added a comment - - edited

            The default account appears to have been intended to use the email address from Jenkins Location, as an Admin Account Address field is not displayed for it in the Jenkins UI. However, additional accounts appear to have been intended to store their own addresses, as the UI shows an Admin Account Address field for each one.

            There appear to be a few bugs in this logic. As noted above, the email address for the default account seems to be copied from the Jenkins Location but never updated when the Jenkins Location email address changes. Another theoretical problem is that hudson.plugins.emailext.ExtendedEmailPublisher#createMail uses the address from the default account even when the session (created in hudson.plugins.emailext.ExtendedEmailPublisherDescriptor#createSession) picked an additional account. I say "theoretical problem" because this functionality has no integration test coverage, nor is there an integration test for the migration logic.

            Show
            basil Basil Crow added a comment - - edited The default account appears to have been intended to use the email address from Jenkins Location, as an Admin Account Address field is not displayed for it in the Jenkins UI. However, additional accounts appear to have been intended to store their own addresses, as the UI shows an Admin Account Address field for each one. There appear to be a few bugs in this logic. As noted above, the email address for the default account seems to be copied from the Jenkins Location but never updated when the Jenkins Location email address changes. Another theoretical problem is that hudson.plugins.emailext.ExtendedEmailPublisher#createMail uses the address from the default account even when the session (created in hudson.plugins.emailext.ExtendedEmailPublisherDescriptor#createSession ) picked an additional account. I say "theoretical problem" because this functionality has no integration test coverage, nor is there an integration test for the migration logic.
            Hide
            basil Basil Crow added a comment -

            Fixed in jenkinsci/email-ext-plugin#249.

            Incremental build 2.77-rc1393.a8de7cb48ce2 is available for testing. The incremental build is available from: https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/email-ext/2.77-rc1393.a8de7cb48ce2/

            Gunnar Grim and Dave Fox, can you please test the incremental build and confirm the issue is resolved? For instructions on how to install a custom build, see: https://www.jenkins.io/doc/book/managing/plugins/#advanced-installation

            Show
            basil Basil Crow added a comment - Fixed in jenkinsci/email-ext-plugin#249 . Incremental build 2.77-rc1393.a8de7cb48ce2 is available for testing. The incremental build is available from: https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/email-ext/2.77-rc1393.a8de7cb48ce2/ Gunnar Grim and Dave Fox , can you please test the incremental build and confirm the issue is resolved? For instructions on how to install a custom build, see: https://www.jenkins.io/doc/book/managing/plugins/#advanced-installation
            Hide
            basil Basil Crow added a comment -

            Released in 2.78.

            Show
            basil Basil Crow added a comment - Released in 2.78 .

              People

              Assignee:
              basil Basil Crow
              Reporter:
              gugrim Gunnar Grim
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: