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

Global environment variables are not being resolved in Email Notification Recipients list for maven 2/3 projects

    Details

    • Similar Issues:

      Description

      When using a global environment variable, defined in "Manage Jenkins > Configure System > Environment Variables" (e.g. "ALERT_EMAIL_LIST"), in the "Email Notification > Recipients" list of a maven 2/3 project (e.g. "${ALERT_EMAIL_LIST}") the environment variable is not resolved. In the console output we see: "Sending e-mails to: ${ALERT_EMAIL_LIST}@test.com".

      Note that it DOES work in an "free-style software project".

      So, it does not work within <hudson.maven.reporters.MavenMailer>, but it does work within <hudson.tasks.Mailer>.

        Attachments

          Activity

          Hide
          jfreej jfreej added a comment -

          Update: Simple build parameters are not working either. When I create a build parameter "ALERT_EMAIL_LIST" and set "Email Notification > Recipients" to "${ALERT_EMAIL_LIST}", I see: "Sending e-mails to: ${ALERT_EMAIL_LIST}@test.com".

          Again, this only applies to <hudson.maven.reporters.MavenMailer>.

          Show
          jfreej jfreej added a comment - Update: Simple build parameters are not working either. When I create a build parameter "ALERT_EMAIL_LIST" and set "Email Notification > Recipients" to "${ALERT_EMAIL_LIST}", I see: "Sending e-mails to: ${ALERT_EMAIL_LIST}@test.com". Again, this only applies to <hudson.maven.reporters.MavenMailer>.
          Hide
          slide_o_mix Alex Earl added a comment -

          Email Notification is not the email-ext plugin.

          Show
          slide_o_mix Alex Earl added a comment - Email Notification is not the email-ext plugin.
          Hide
          bduffy Brent Duffy added a comment -

          We are seeing a similar issue with freestyle jobs on Jenkins 2.32.1. The problem we are seeing is that if an environment variable (or build parameter) isn't defined, the variable name is treated as a string literal instead of an empty string. We see this behavior in the "Recipients" field for the built-in "E-mail notification" post-build action as well as the "Project Recipient List" for the "Editable Email Notification" post-build action provided by the email-ext plugin. To replicate this issue, try to refer to an undefined environment variable in one of those fields. The environment variable syntax we're using in the recipient list is:

          emailaddress1 emailaddress2 ${TEST_EMAIL_LIST}

          Basically, emails will always be delivered to emailaddress1 and emailaddress2, but some jobs need to supply additional email addresses via the TEST_EMAIL_LIST build parameter. We have a job that is a downstream to several other jobs. Some of the upstream jobs (but not all) supply TEST_EMAIL_LIST as a build parameter to the downstream job. When the variable is actually defined, everything works as expected, however when it is not defined, both the built-in "Email notification" and the "Editable Email Notification" plugin will try to send an email to the address "$TEST_EMAIL_LIST", which causes an error since it is not a valid address. We would expect that an undefined environment variable would be treated as an empty string, which is how they are treated in the bash shell.

          Show
          bduffy Brent Duffy added a comment - We are seeing a similar issue with freestyle jobs on Jenkins 2.32.1. The problem we are seeing is that if an environment variable (or build parameter) isn't defined, the variable name is treated as a string literal instead of an empty string. We see this behavior in the "Recipients" field for the built-in "E-mail notification" post-build action as well as the "Project Recipient List" for the "Editable Email Notification" post-build action provided by the email-ext plugin. To replicate this issue, try to refer to an undefined environment variable in one of those fields. The environment variable syntax we're using in the recipient list is: emailaddress1 emailaddress2 ${TEST_EMAIL_LIST} Basically, emails will always be delivered to emailaddress1 and emailaddress2, but some jobs need to supply additional email addresses via the TEST_EMAIL_LIST build parameter. We have a job that is a downstream to several other jobs. Some of the upstream jobs (but not all) supply TEST_EMAIL_LIST as a build parameter to the downstream job. When the variable is actually defined, everything works as expected, however when it is not defined, both the built-in "Email notification" and the "Editable Email Notification" plugin will try to send an email to the address "$TEST_EMAIL_LIST", which causes an error since it is not a valid address. We would expect that an undefined environment variable would be treated as an empty string, which is how they are treated in the bash shell.
          Hide
          priyankbamoriya Priyank Bamoriya added a comment -

          Facing same issue. Do we have any resolution for that?

          Show
          priyankbamoriya Priyank Bamoriya added a comment - Facing same issue. Do we have any resolution for that?
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: André Tadeu de Carvalho
          Path:
          src/main/java/hudson/maven/MavenModuleSetBuild.java
          src/main/java/hudson/maven/reporters/MavenMailer.java
          src/main/java/hudson/maven/util/VariableExpander.java
          src/test/java/hudson/maven/reporters/MavenMailerTest.java
          src/test/java/hudson/maven/util/VariableExpanderTest.java
          http://jenkins-ci.org/commit/maven-plugin/f6112cb4e7fece3c5dd48c93a68f61649bad0b7b
          Log:
          JENKINS-13277 Global Environment Variables in Email notification. (#101)

          • JENKINS-13277 Fix 'Global environment variables are not being resolved in Email Notification Recipients list for maven 2/3 projects'
          • Add integration tests.
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: André Tadeu de Carvalho Path: src/main/java/hudson/maven/MavenModuleSetBuild.java src/main/java/hudson/maven/reporters/MavenMailer.java src/main/java/hudson/maven/util/VariableExpander.java src/test/java/hudson/maven/reporters/MavenMailerTest.java src/test/java/hudson/maven/util/VariableExpanderTest.java http://jenkins-ci.org/commit/maven-plugin/f6112cb4e7fece3c5dd48c93a68f61649bad0b7b Log: JENKINS-13277 Global Environment Variables in Email notification. (#101) JENKINS-13277 Fix 'Global environment variables are not being resolved in Email Notification Recipients list for maven 2/3 projects' Add integration tests.

            People

            • Assignee:
              olamy Olivier Lamy
              Reporter:
              jfreej jfreej
            • Votes:
              5 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: