4
votes

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

2
Have you done anything similar in a freestyle job? Or is this a more general question if email-ext plugin supports it at all?Jon S
I just need to know how to embed image in emailext use in pipeline (not freestyle).Nir Koren
Yes I understand that, however I did some research and found no obvious way to do it in general (regardless of pipeline or freestyle). So I'm just wondering if you have managed to do it in a freestyle job and now are trying to convert that to pipeline?Jon S

2 Answers

2
votes

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.

-1
votes

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.