zoukankan      html  css  js  c++  java
  • Jenkins发送邮件 How to let a html with JavaScript can display in Outlook?

    I encounter a problem like this:

    As you know, we config html format email in Jenkins.

    I need to insert several images in the HTML.But I am sure about how many images there will be, as it is determined by the actual situation.

    So , i write a For Loop using JavaScript in the html to create <img src=""></img> dynamically. But Outlook cannot execute JavaScript.

    I think if i can convert the html with JavaScript to actual HTML, it will work.

    So, I think out write python code to generate the HTML and save it to the Jenkins WorkSpace.

    Divide the original HTML to 2 parts. The second part will only contain the images and generated by python.

    fp = open("report.html","w+b") #打开一个文本文件

    for i in range(1,imgCount+1):

    fp.write('<img src="report'+str(i)+'.png"></img>') #写入数据

    fp.close() #关闭文件

    Above code will be added under the original python script which is used to take screenshots and divide one image to several images, of course the original python code also need to change, as the image count was hard coded before.

    imgCount = h/2000+1

    size=h/imgCount

    left = 0

    shang = 0

    index = 0

    for i in range(imgCount):

    i=i+1

    shang += 1

    a = size * left

    b = size *(i-1)

    c = w

    d = size * i

    region = im.crop((a, b, c, d))

    region.save("report%s.png" %i)

    And then, append ${FILE,path="report.html"} in the end of Default Content under Editable Email Notification in Jenkins.

    Don't forget to change the Attachments to use Regular Expression : Report*.png

    At Last, delete below content in Default Content under Editable Email Notification in Jenkins.

    <tr>

    <td align="center"><img src="result1.png" /><img src="result2.png" /><img src="result3.png" /><img src="result4.png" /><img src="result5.png" />

    <hr size="1" width="100%" align="center" /></td>

    </tr>

  • 相关阅读:
    cpp学习
    7-2 求逆序对数目 (20分) 归并排序 O(nlogn)
    Egret 滚动背景图的实现
    Egret-我的疑问:Scroller如何禁止水平或垂直方向滚动
    Egret-我的探索:exml自定义组件中通过ID获取子组件实例
    Egret-我的疑问:自定义组件加载skin的操作
    Egret事件冒泡的应用
    Egret点击穿透(使遮盖可点击组件的其他组件禁止点击)
    Egret wing 4.1.6项目目录结构
    Egret分步加载资源改写loading界面
  • 原文地址:https://www.cnblogs.com/MasterMonkInTemple/p/14736035.html
Copyright © 2011-2022 走看看