How to modify the mime message in editable email plugin in jenkins

半世苍凉 提交于 2019-12-31 03:36:10

问题


i'd like to modify the email message i send from jenkins. how can i do it? i tried to use msg variable and set the content using msg.setContent("this is the string i want in the email body") but it failed any ideas?


回答1:


I've just faced same task:

msg.setContent("Test content", 'text/html') 

worked for me.

I guess possible types are 'text/html' and 'text/plain', check that you are changing the proper one.




回答2:


msg.setContent doesn't send messages if the GString type passed as content.

Don't forget to convert GString to java.lang.String

Use toString()

def gStringContent = "Hellow ${name}"
logger.println 'Content type is ' + gStringContent.getClass()
msg.setContent(gStringContent.toString(), 'text/html')

Use explicit typing String

String gStringContent = """Hello $name
Goodby ${name}"""
logger.println 'Content type is ' + gStringContent.getClass()
msg.setContent(gStringContent.toString(), 'text/html')

etc.

That's was my trouble. Fixed.



来源:https://stackoverflow.com/questions/17262161/how-to-modify-the-mime-message-in-editable-email-plugin-in-jenkins

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