• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • email-ext-plugin
    • None
    • Jenkins 2.249.1. Email ext plugin 2.77.
    • 2.78

      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.

          [JENKINS-63846] From address can't be changed

          Alex Earl added a comment -

          The admin email comes from the Jenkins Location area of the Global Configuration if it exists. Are you saying you can't change it in that field in the Global Configuration?

          Alex Earl added a comment - The admin email comes from the Jenkins Location area of the Global Configuration if it exists. Are you saying you can't change it in that field in the Global Configuration?

          Dave Fox added a comment - - edited

          Changing the email address in that location through the web UI doesn't work, that's the core issue here. It will look like it worked, as the display will save and update if you go out and back into the Global Configuration, but it won't change when the system sends out emails.

          It used to work until one of the recent plug-in updates, as in our workflow we change this from address about every three weeks or so. To get around this for now, I've had to manually edit the file jenkins.model.JenkinsLocationConfiguration.xml on the Controller, as Gunnar has noted in this ticket's Description.

          Dave Fox added a comment - - edited Changing the email address in that location through the web UI doesn't work, that's the core issue here. It will look like it worked, as the display will save and update if you go out and back into the Global Configuration, but it won't change when the system sends out emails. It used to work until one of the recent plug-in updates, as in our workflow we change this from address about every three weeks or so. To get around this for now, I've had to manually edit the file jenkins.model.JenkinsLocationConfiguration.xml on the Controller, as Gunnar has noted in this ticket's Description.

          Alex Earl added a comment -

          Ok, I'll take a look.

          Alex Earl added a comment - Ok, I'll take a look.

          Tim Jacomb added a comment -

          fyi basil

          Tim Jacomb added a comment - fyi 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.

          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 .

          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.

          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.

          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.

          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.

          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/

          gugrim and dfox0, 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

          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/ gugrim and dfox0 , 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

          Basil Crow added a comment -

          Released in 2.78.

          Basil Crow added a comment - Released in 2.78 .

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

              Created:
              Updated:
              Resolved: