Nir Koren
Nir Koren

Reputation: 261

Using Jenkins email-ext plugin with pipeline

I am running from my pipeline a snippet to send html mail from HTML file. it looks like that:

emailext(to: "${BUILD_USER_EMAIL}", mimeType: 'text/html', subject: "dummy subject", body: readFile 'pipeline/mail/summary.html');

My question: How can I embed image file (as part of the mail) using CID or something similar? it only works if I am adding the IMG tag to my HTML file linking to a url that actually available from my org. I just need the image to be embedded as part of the mail. Thanks, Nir

Upvotes: 4

Views: 10303

Answers (2)

Tim Harden
Tim Harden

Reputation: 76

You can embed an image via base64. Convert the image here or however you want then enter it into your pipeline script like this:

(example is from Jenkinsfile)

emailext attachmentsPattern: '%JENKINS_HOME%/changelog.xml', body: '<img src="data:image/png;base64,iVBORw0K...shortened...rkJggg==">', mimeType: 'text/html', subject: 'Look at this subject!', to: '[email protected]'

Very important, the latest version can only support up to 65535 characters in the body and the encoding can easily surpass that limit.

Upvotes: 2

Dustin Oprea
Dustin Oprea

Reputation: 10236

That's going to be too advanced for the likes of Jenkins. It's not meant to provide the general ability to attach and embed things.

You should just do this in Python (pass the list of recipients) and add it as a step.

Upvotes: -1

Related Questions