Jenkins: $ {BUILD_LOG, maxLines, escapeHtml} does not work

I am trying to use "$ {BUILD_LOG, maxLines, escapeHtml}" as described in: How can I take the last 20 lines from the $ BUILD_LOG variable?

Unfortunately, this does not work for me.

I get this error:

Script1.groovy: 114: expect nothing but '' \ n ''; got it anyway @ row 114, column 301. arted by user MYUSERNAME

My code on this line is:

msg.setText("This build (" + build.getFullDisplayName() + " ) contains the following tasks:\n\nTASK\t\t\t IMPLEMENTER:\n" + taskList + "\n\n\nLink to this build: ${BUILD_URL} \n ${BUILD_LOG, maxLines=9999, escapeHtml=false}" ); 

If I choose this from the following, it will work. That is why I assume that " BUILD_LOG " is no longer working?

$ {BUILD_LOG, maxLines = 9999, escapeHtml = false}


EDIT: Perhaps as a complement: I'm trying to do this with a PreSend groovy script. Because I am building email text dynamically. ${BUILD_URL} works fine, ${BUILD_LOG, maxLines=9999, escapeHtml=false} doesn't (for me) I'm looking for a solution for this ... the msg object is java MimeMessage.

Thanks Daniel

+6
source share
4 answers

This error message is usually associated with closed quotation marks, comments begin with / instead of // , etc. In your code, the only thing I see is that your third line is not finished correctly, i.e. after "\n\n\nLink to this you do not close double quotes, and instead you start a new line (thereby expecting anything but ''\n'' .

Try writing the whole line:

 msg.setText("This build (" + build.getFullDisplayName() + " ) contains the following tasks:\n\nTASK\t\t\t IMPLEMENTER:\n" + taskList + "\n\n\nLink to this build: ${BUILD_URL} \n ${BUILD_LOG, maxLines=9999, escapeHtml=false}" ); 

or close quotes:

 msg.setText("This build (" + build.getFullDisplayName() + " ) contains the following tasks:\n\nTASK\t\t\t IMPLEMENTER:\n" + taskList + "\n\n\nLink to this " + "build: ${BUILD_URL} \n ${BUILD_LOG, maxLines=9999, escapeHtml=false}" ); 
+1
source

I used below and it works great for me.

 ${BUILD_LOG, maxLines=10, escapeHtml=false} 

I tried with Jenkins version 1.617

0
source

Have you tried setting escapeHtml=true ? It may happen that this token is expanded as is, and then the line in " " becomes invalid.

0
source

In the latest version, the variable $ {BUILD_LOG} is not available to me - for me, only the solution for registering email content was installed:

 msg.setText(build.getLog()) 

as standard script pre-shipment in Jenkins global configuration ...

0
source

All Articles