Jenkins Graphs in embedded in mail or as attachment

元气小坏坏 提交于 2019-12-11 10:02:37

问题


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.

like the one that shown below. http://s22.postimg.org/8619l7msx/jenkins_Graph.jpg


回答1:


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

  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.

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

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.




回答2:


Instead of using the $JOB_URL use $JOB_NAME to use the job id and reach the location.

e.g. $JOB_NAME/workspace/... would work.



来源:https://stackoverflow.com/questions/22298036/jenkins-graphs-in-embedded-in-mail-or-as-attachment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!