Jenkins: ${BUILD_LOG, maxLines, escapeHtml} not wo

2019-04-29 06:55发布

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

Unfortunately it doesn't work for me.

I get this error:

Script1.groovy: 114: expecting anything but ''\n''; got it anyway @ line 114, column 301. arted by user MYUSERNAME

My code in 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 take this out the following, it works. Thats why my guess is, that "BUILD_LOG" is not working anymore?

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


EDIT: Maybe as addition: I am trying to do this withing the PreSend groovy script. Since I am building the Email text dynamically. ${BUILD_URL} works fine, ${BUILD_LOG, maxLines=9999, escapeHtml=false} doesn't (for me) i am looking for a solution for this... the msg object is a java MimeMessage.

Thanks, Daniel

4条回答
地球回转人心会变
2楼-- · 2019-04-29 07:35

I used the below and it's working fine for me.

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

I tried with Jenkins version 1.617

查看更多
贪生不怕死
3楼-- · 2019-04-29 07:36

In latest version variable ${BUILD_LOG} wasn't available for me - only solution to get log in email content was for me setting:

msg.setText(build.getLog())

as Default Pre-send Script in Jenkins global configuration...

查看更多
放荡不羁爱自由
4楼-- · 2019-04-29 07:37

That error message is usually related to not closed quotes, comments started with / instead of //, etc. In your code the only thing I can see is that your third line is not finished properly, i.e., after "\n\n\nLink to this you are not closing double quotes and instead you are starting a new line (thereby the expecting anything but ''\n''.

Try to write 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 the quotes instead:

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}" );
查看更多
家丑人穷心不美
5楼-- · 2019-04-29 07:46

Have you tried to set escapeHtml=true? It may happen that this token expanded as is and then string in " " becomes not valid.

查看更多
登录 后发表回答