Jenkins嵌入邮件或附件中的图形 [英] Jenkins Graphs in embedded in mail or as attachment

查看:571
本文介绍了Jenkins嵌入邮件或附件中的图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在构建作业之后将Jenkins_URL / job / JOB_Name / buildTimeGraph / png和/或Jenkins_URL / job / JOB_Name / test / trend图保存为图像,并将它们发送到嵌入或作为附件使用邮件插件。

Is it possible to save "Jenkins_URL/job/JOB_Name/buildTimeGraph/png" and/or "Jenkins_URL/job/JOB_Name/test/trend" graphs as images after the job is build and them send them embedded or as attachment using a mail plugin.

如下所示。
http://s22.postimg.org/8619l7msx/jenkins_Graph.jpg

推荐答案

我可以建议一个不安的方式。下列工作应该逐步完成:

I can suggest one unelegant way. The following should be done step by step inside your job:


  1. 将图形下载到png以构建工作区,即 wget -O脚本构建步骤中的-O time_graph.png $ {JOB_URL} / buildTimeGraph / png $ {JOB_URL} 是Jenkins的一个env var set。不要忘记让你的工作显示为匿名的,否则下载将无法正常工作。

  2. 将下载的png存档到构建的工件中。

  3. 将内容类型设置为html,用于您的电子邮件ext plugin postbuild步骤。

  4. < img src =$ {BUILD_URL} /artifact/time_graph.png/> ; 到您的电子邮件模板正文。 $ {BUILD_URL} 通过电子邮件扩展插件解析为当前版本的URL。

  5. 完成。

  1. Download graph as png to build workspace, i.e. wget -O time_graph.png ${JOB_URL}/buildTimeGraph/png in a shell script build step. ${JOB_URL} is an env var set by Jenkins. Don't forget to make your job visible for anonymous otherwise download wouldn't work without authorization.
  2. Archive downloaded png into your build's artifacts.
  3. Set content type to html for your email ext plugin postbuild step.
  4. Place <img src="${BUILD_URL}/artifact/time_graph.png" /> into your email template body. ${BUILD_URL} is resolved by email-ext plugin to a URL to the current build.
  5. Done.

为什么需要下载和归档,但不仅仅是< img src =$ {PROJECT_URL} / buildTimeGraph / png/> 在电子邮件正文中?

Why need download and archiving but not just <img src="${PROJECT_URL}/buildTimeGraph/png" /> in the email body?

因为否则电子邮件中显示的趋势img将反映当它下载时的情况(因为它是根据请求生成的)而不是当电子邮件发送的那一刻。如果它适合你,请使用第二种方法,因为它更简单。

Because otherwise the trend img which is shown in the email will reflect the situation for the moment when it was dowloaded (cause it's generated on request) and not for the moment when email was sent. If it suits you, use the second way as it much simplier.

这篇关于Jenkins嵌入邮件或附件中的图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆