Using Jenkins email plugin with pipeline
I am running from my pipeline a snippet to send html mail from an HTML file. it looks like this:
emailext(to: "${BUILD_USER_EMAIL}", mimeType: 'text/html', subject: "dummy subject", body: readFile 'pipeline/mail/summary.html');
My question is, how can I embed an image file (as part of a mail) using a CID or something similar? it only works if I add an IMG tag to my HTML file referencing a URL that is actually reachable from my organization. I just need the image to be embedded as part of the mail. Thanks, Nir
+3
source to share
2 answers
You can embed image via base64. Convert the image here, or if you like, inject it into your script pipeline like this:
(example from Jenkins file)
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@address.com'
It is very important that the latest version can only support up to 65535 characters in the body, and the encoding can easily surpass this limit.
+1
source to share