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

email-ext cannot expand ${FAVORITE_USERS_EMAIL} macro in pipeline

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      When passing the ${FAVORITE_USERS_EMAIL} macro in the 'to:' line of a pipeline call to email-ext, jenkins errors with: "FAVORITE_USERS_EMAIL" is not supported in this context. 

      I also cannot expand the ${FAVORITE_USERS_EMAIL} token using the 'tk' step to get the list of users who have favorited a job and include them in the email. The same error message is thrown. 

        Attachments

          Activity

          Hide
          davidvanlaatum David van Laatum added a comment -

          Personally I would code as RecipientProvider rather than a token.

          Show
          davidvanlaatum David van Laatum added a comment - Personally I would code as RecipientProvider rather than a token.
          Hide
          jamesdumay James Dumay added a comment -

          Can you please provide an example Jenkinsfile?

          Show
          jamesdumay James Dumay added a comment - Can you please provide an example Jenkinsfile?
          Hide
          raorao rao rao added a comment -

          I too hit the same issue this morning. Any update or workaround with this issue?

          Show
          raorao rao rao added a comment - I too hit the same issue this morning. Any update or workaround with this issue?
          Hide
          kmleinen Kyle Leinen added a comment -

          Anyone have an example that James can look at?  If not, I'll try and come up with one as I would like to get this resolved.

          Show
          kmleinen Kyle Leinen added a comment - Anyone have an example that James can look at?  If not, I'll try and come up with one as I would like to get this resolved.
          Hide
          kmleinen Kyle Leinen added a comment - - edited

          We tried this was various escape char combos for the "$", but we found that the environment variable on our system isn't showing up even for a simple echo call.

          pipeline {
              agent none
          
              stages {
                  stage('Test Email') {
                      agent any
                      steps {
                          script {
                              try {
                                 echo "emailext body: 'Hello World', recipientProviders: [recipients()], subject: 'Hi', to: '\$FAVORITE_USERS_EMAIL'"
                                 emailext body: 'Hello World - fifth', recipientProviders: [recipients()], subject: 'Hi', to: '\$FAVORITE_USERS_EMAIL'
                              } catch(e) {
                                 echo "${e.getMessage()}"
                                 echo "Failed to send email"
                              }
                          }
                      }
                  }
              }
          }
          
          Show
          kmleinen Kyle Leinen added a comment - - edited We tried this was various escape char combos for the "$", but we found that the environment variable on our system isn't showing up even for a simple echo call. pipeline { agent none stages { stage( 'Test Email' ) { agent any steps { script { try { echo "emailext body: 'Hello World' , recipientProviders: [recipients()], subject: 'Hi' , to: '\$FAVORITE_USERS_EMAIL' " emailext body: 'Hello World - fifth' , recipientProviders: [recipients()], subject: 'Hi' , to: '\$FAVORITE_USERS_EMAIL' } catch (e) { echo "${e.getMessage()}" echo "Failed to send email" } } } } } }
          Hide
          slide_o_mix Alex Earl added a comment -

          is FAVORITE_USERS_EMAIL a token, or just a parameter?

          Show
          slide_o_mix Alex Earl added a comment - is FAVORITE_USERS_EMAIL a token, or just a parameter?

            People

            • Assignee:
              jamesdumay James Dumay
              Reporter:
              bbyjnks m c
            • Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated: