Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Email-ext and Workflow/Pipeline - some tokens not being expanded?

I'm trying to use the email-ext plugin in a Jenkins pipeline job, but most of the tokens I take for granted when using email-ext in a freestyle job aren't being expanded?

e.g.

node {
    emailext body: '${DEFAULT_CONTENT}', mimeType: 'text/html', replyTo: '$DEFAULT_REPLYTO', subject: '${DEFAULT_SUBJECT}', to: '$DEFAULT_RECIPIENTS'
}

Generates the email:

Subject:

$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!

Body:

$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results.

Which are, in fairness, what is set in the general configuration. However, none of those tokens are expanded, and if I use them directly from workflow, they're not expanded either, e.g.

emailext body: '$PROJECT_NAME', mimeType: 'text/html', replyTo: '$DEFAULT_REPLYTO', subject: '${DEFAULT_SUBJECT}', to: '$DEFAULT_RECIPIENTS'

This would be 'okay' if I was able to reference my existing Groovy-based email templates using $SCRIPT, but those aren't expanded either.

Apologies if I'm missing something incredibly obvious - I don't have much experience with Pipeline yet - the lack of email-ext support has stopped me from moving across thus far.

I tested today by clean installing Jenkins 1.651, email-ext 2.41.3 and Pipeline 1.14.

like image 334
Phil McArdle Avatar asked Mar 04 '16 10:03

Phil McArdle


1 Answers

The tokens are highly tied to AbstractBuild, which workflow doesn't use. So, the tokens won't be replaced correctly right now. I need to modify the token-macro plugin (which is the basis for the token expansion) so that it will work with a Run object instead of just AbstractBuild, but this is a large task that I haven't had the change to do yet. You could generate the same content using the workflow DSL.

like image 197
slide Avatar answered Nov 03 '22 07:11

slide