[JIRA] (JENKINS-47773) email-ext cannot expand ${FAVORITE_USERS_EMAIL} macro in pipeline

19 views
Skip to first unread message

kleinen@gmail.com (JIRA)

unread,
Jun 11, 2018, 11:49:02 AM6/11/18
to jenkinsc...@googlegroups.com
Kyle Leinen commented on Bug JENKINS-47773
 
Re: email-ext cannot expand ${FAVORITE_USERS_EMAIL} macro in pipeline

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.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

kleinen@gmail.com (JIRA)

unread,
Jun 11, 2018, 11:58:03 AM6/11/18
to jenkinsc...@googlegroups.com

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.

Unable to find source-code formatter for language: groovy. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
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"
                    }
                }
            }
        }
    }
}

kleinen@gmail.com (JIRA)

unread,
Jun 11, 2018, 11:58:04 AM6/11/18
to jenkinsc...@googlegroups.com
Kyle Leinen edited a comment on Bug JENKINS-47773
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.

{code: groovy java }

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"
                    }
                }
            }
        }
    }
}
{code}

slide.o.mix@gmail.com (JIRA)

unread,
Mar 22, 2019, 9:31:02 AM3/22/19
to jenkinsc...@googlegroups.com

is FAVORITE_USERS_EMAIL a token, or just a parameter?

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

slide.o.mix@gmail.com (JIRA)

unread,
Jul 17, 2019, 10:50:03 AM7/17/19
to jenkinsc...@googlegroups.com
Alex Earl closed an issue as Incomplete
 
Jenkins / Bug JENKINS-47773
Change By: Alex Earl
Status: Open Closed
Resolution: Incomplete

slide.o.mix@gmail.com (JIRA)

unread,
Jul 17, 2019, 10:50:05 AM7/17/19
to jenkinsc...@googlegroups.com

rao8218@gmail.com (JIRA)

unread,
Jul 17, 2019, 2:06:04 PM7/17/19
to jenkinsc...@googlegroups.com
rao rao commented on Bug JENKINS-47773
 
Re: email-ext cannot expand ${FAVORITE_USERS_EMAIL} macro in pipeline

The workaround that i did is below.

 

def email_list = []
if(fileExists ('favorites.txt')) {
 def file_contents = readFile 'favorites.txt'
email_list = file_contents.tokenize('\n')
 echo "FILE CONTENTS OF FAVORITES ARE -- ${email_list}"
 } else {
 echo "FAVORITES FILE DOESNT EXIST"
 }
emailext body: "${email_job_url}${currentBuild.description}", recipientProviders: [[$class: 'RequesterRecipientProvider']], mimeType: 'text/html', subject: "Pipeline '${env.JOB_NAME}' was ${currentBuild.result}", to: "${email_list.join(',')}"

 

 

kleinen@gmail.com (JIRA)

unread,
Jul 17, 2019, 2:11:02 PM7/17/19
to jenkinsc...@googlegroups.com

rao8218@gmail.com (JIRA)

unread,
Jul 17, 2019, 2:12:05 PM7/17/19
to jenkinsc...@googlegroups.com
rao rao commented on Bug JENKINS-47773

The Favorites plugin generates that file for each job that has been Favorited.

slide.o.mix@gmail.com (JIRA)

unread,
Jul 17, 2019, 2:14:03 PM7/17/19
to jenkinsc...@googlegroups.com

Where is FAVORITE_USERS_EMAIL defined? Is it a job parameter, or an environment variable? I don't think it is a token (from token-macro). If it's a parameter or environment variable, you should be able to access it as:

emailext body: 'Hello World - fifth', recipientProviders: [recipients()], subject: 'Hi', to: FAVORITE_USERS_EMAIL

or

rao8218@gmail.com (JIRA)

unread,
Jul 17, 2019, 2:24:02 PM7/17/19
to jenkinsc...@googlegroups.com
rao rao commented on Bug JENKINS-47773

FAVORITE_USERS_EMAIL is a Token Macro as part of [Favorite |https://plugins.jenkins.io/favorite] plugin.

slide.o.mix@gmail.com (JIRA)

unread,
Jul 17, 2019, 2:29:03 PM7/17/19
to jenkinsc...@googlegroups.com

That token won't work in a pipeline job, it has not been updated to support pipeline.

slide.o.mix@gmail.com (JIRA)

unread,
Jul 17, 2019, 2:29:04 PM7/17/19
to jenkinsc...@googlegroups.com

slide.o.mix@gmail.com (JIRA)

unread,
Jul 17, 2019, 2:29:04 PM7/17/19
to jenkinsc...@googlegroups.com

slide.o.mix@gmail.com (JIRA)

unread,
Jul 17, 2019, 2:31:03 PM7/17/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages