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

六月ゝ 毕业季﹏ 提交于 2019-12-07 02:57:41

问题


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


回答1:


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}" );



回答2:


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:


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




回答4:


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...



来源:https://stackoverflow.com/questions/32697156/jenkins-build-log-maxlines-escapehtml-not-working

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