2
votes

I am trying to write a jelly script in Jenkins Email-Ext that returns part of the console output. I am trying to loop through console output for 'failure'. Can someone give me a sample script or format for doing this using jelly script template?

Thanks in advance.

1

1 Answers

1
votes

Maybe you can also use Groovy, as with jelly is likely harder to do something like that.

The sample that is included as part of email-ext here does something like that with Groovy, i.e. it retrieves the last 100 lines of build output and then uses StringEscapeUtils on each line to ensure that the text is not interpreted as HTML:

<%  build.getLog(100).each() { line -> %>
<TR><TD class="console">${org.apache.commons.lang.StringEscapeUtils.escapeHtml(line)}</TD></TR>
<%  } %>

instead of the escaping, you could do some decision and only output stuff if the condition holds, e.g.

${if(line.contains('mytext')) { // do stuff here }}