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

Email recipients should support use of build parameters

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • None

      The recipients list for email notification should support parameter expansion.

          [JENKINS-6394] Email recipients should support use of build parameters

          Code changed in hudson
          User: : abayer
          Path:
          trunk/hudson/main/core/src/main/java/hudson/tasks/Mailer.java
          http://jenkins-ci.org/commit/30485
          Log:
          [FIXED JENKINS-6394] Email recipient lists now support build parameters

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : abayer Path: trunk/hudson/main/core/src/main/java/hudson/tasks/Mailer.java http://jenkins-ci.org/commit/30485 Log: [FIXED JENKINS-6394] Email recipient lists now support build parameters

          This does not appear to work (tested in 1.361). Either I've misunderstood the feature, or it's broken.

          On the main Hudson configuration page, I defined an environment variable HUDSON_EMAILS_FOR_GDA_ADMINISTRATOR and an associated value.
          In the configuration for a specific job, I specified an email recipient list of ${HUDSON_EMAILS_FOR_GDA_ADMINISTRATOR}. This is the standard Hudson email, not the extended email plugin.

          When the job fails and tries to send an email, I get
          com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <${HUDSON_EMAILS_FOR_GDA_ADMINISTRATOR}>... User unknown

          I displayed the value of the environment variable in one of the build steps, and it is set correctly.

          Matthew Webber added a comment - This does not appear to work (tested in 1.361). Either I've misunderstood the feature, or it's broken. On the main Hudson configuration page, I defined an environment variable HUDSON_EMAILS_FOR_GDA_ADMINISTRATOR and an associated value. In the configuration for a specific job, I specified an email recipient list of ${HUDSON_EMAILS_FOR_GDA_ADMINISTRATOR}. This is the standard Hudson email, not the extended email plugin. When the job fails and tries to send an email, I get com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <${HUDSON_EMAILS_FOR_GDA_ADMINISTRATOR}>... User unknown I displayed the value of the environment variable in one of the build steps, and it is set correctly.

          Alan Harder added a comment -

          From the commit above, it looks like it was implemented to only evaluate against parameters specifically for that build.. so your global env var is not used.
          abayer, could this be changed to get the EnvVars from build.getEnvironment and call env.expand() instead?

          Alan Harder added a comment - From the commit above, it looks like it was implemented to only evaluate against parameters specifically for that build.. so your global env var is not used. abayer, could this be changed to get the EnvVars from build.getEnvironment and call env.expand() instead?

          Code changed in hudson
          User: : mindless
          Path:
          trunk/hudson/main/core/src/main/java/hudson/tasks/Mailer.java
          trunk/hudson/main/core/src/main/resources/hudson/tasks/Mailer/config.properties
          http://jenkins-ci.org/commit/33098
          Log:
          [FIXED JENKINS-6394] use EnvVars to expand parameters in recipient list
          (not just ParametersAction), don't overwrite the field in this object
          when parameters are expanded, and note that parameters are supported in
          the help text.
          Also correct the help text that mentions when email is sent.

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : mindless Path: trunk/hudson/main/core/src/main/java/hudson/tasks/Mailer.java trunk/hudson/main/core/src/main/resources/hudson/tasks/Mailer/config.properties http://jenkins-ci.org/commit/33098 Log: [FIXED JENKINS-6394] use EnvVars to expand parameters in recipient list (not just ParametersAction), don't overwrite the field in this object when parameters are expanded, and note that parameters are supported in the help text. Also correct the help text that mentions when email is sent.

          This still fails for me, exactly as per my comment of 7/Jun/2010 - The failure is with Hudson 1.368 and email-ext 2.6.
          For a recipient list that contains a $ENVVAR, the substitution is not performed - I tried with both core email, and extended email plugin.

          Matthew Webber added a comment - This still fails for me, exactly as per my comment of 7/Jun/2010 - The failure is with Hudson 1.368 and email-ext 2.6. For a recipient list that contains a $ENVVAR, the substitution is not performed - I tried with both core email, and extended email plugin.

          I'm bumping the priority simply because of the various unsuccessful attempts to fix this. If someone has time to take a look at it, and test any fix, that would be great.

          Matthew Webber added a comment - I'm bumping the priority simply because of the various unsuccessful attempts to fix this. If someone has time to take a look at it, and test any fix, that would be great.

          Alan Harder added a comment -

          Hm, looks like global env vars are part of build.getEnvironment() during the build steps but not there in the post-build steps. Digging further..

          Alan Harder added a comment - Hm, looks like global env vars are part of build.getEnvironment() during the build steps but not there in the post-build steps. Digging further..

          Alan Harder added a comment -

          yes, this is the way buildEnvironments is written.

          I'm reclosing this issue. Can you open a new improvement request asking for global environment variables to be made available to post-build actions? Thanks.

          Alan Harder added a comment - yes, this is the way buildEnvironments is written. I'm reclosing this issue. Can you open a new improvement request asking for global environment variables to be made available to post-build actions? Thanks.

          A new improvement request has been opened (JENKINS-7075), as requested.

          Matthew Webber added a comment - A new improvement request has been opened ( JENKINS-7075 ), as requested.

            mindless Alan Harder
            abayer Andrew Bayer
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: