简体   繁体   中英

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

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@address.com'

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM