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>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
2016-05-06 [IIS] 测试的产品登陆之后有个引用外部站点js的请求半天都无法返回,导致网页一直在打转,Selenium的driver也无法对页面进行下一步的操作