在 Jenkins 管道的电子邮件正文中嵌入图像

anu*_*eep 5 html jenkins jenkins-plugins jenkins-pipeline jenkins-email-ext

我需要在电子邮件中添加一个图像作为电子邮件正文而不是附件,从 Jenkins 通过管道。我在 Jenkins 管道中使用 emailext 插件,下面是我正在使用的代码。

emailext (
          subject: "test email",
          body: """
          <html>
          <body>
          <p>please find attached score: Job '${env.JOB_NAME}':</p>
          <p> The last commit was by ${last_commit_user} </p>
          <p>Please check jenkins console at "</p> 
          <p> For detailed report on this analysis, visit "</p>
          </body>
          </html>
          """,
          to: email_recipients,
          attachmentsPattern: '${BUILD_NUMBER}.jpg'
)
Run Code Online (Sandbox Code Playgroud)

我不想使用作为附件的 "attachmentsPattern" ,我尝试使用,

body: """ 
<html>
<img src="image_name.jpg" >
</html>
"""
Run Code Online (Sandbox Code Playgroud)

这只是我电子邮件中的蓝色框,我提供了相对于我的 Jenkins 工作区的正确图像路径,我尝试搜索相关解决方案但徒劳无功。

小智 -2

将镜像文件推送到 jenkins 作业的工作区目录中。
转到工作区并单击图像以获取 URL。
放置img src="IMAGE_URL"在电子邮件模板中。