How to change mime message in jenkins editable email plugin

I want to change the email I am sending from jenkins. How can I do it? I tried to use the msg variable and set the content using msg.setContent ("this is the line I want in the body of the message") but it failed any ideas?

+2
source share
2 answers

I faced the same problem:

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

worked for me.

I assume that the possible types are: "text / html" and "text / plain", check that you are changing the correct one.

+1
source

msg.setContent does not send messages if the GString type GString passed as content.

Remember 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 String input

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

and etc.

That was my problem. Fixed.

0
source

Source: https://habr.com/ru/post/1390620/


All Articles