3

Can I display the contents of another file in my jelly script output?

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
Rnet
  • 4,796
  • 9
  • 47
  • 83

3 Answers3

1

Yes, you can use the ${FILE, path} token to include the contents of a file (path is relative to your workspace directory).

This info is taken from the Content Token Reference in the email-ext part of your job configuration. Click the question mark on the right to get the full list of tokens.

gareth_bowles
  • 20,760
  • 5
  • 52
  • 82
  • Unfortunately that token cannot be used 'inside' a jelly script. I already have a custom jelly script, I'm looking for a way to populate parts of that custom template – Rnet Jun 28 '13 at 21:54
1

If the file is included in the workspace of the job, declare your variable such as:

<j:set var="fileContent" value="${build.getWorkspace().child("results.html")}"/>

And call it this way:

${fileContent}
Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
0

Look at util:loadText which is a "tag which loads text from a file or URI into a Jelly variable."

<u:loadText var="contents" file="${filename}"/>
${contents}

Haven't used it inside of Jenkins before... let us know if it works.

Josh Unger
  • 6,717
  • 6
  • 33
  • 55
  • 1
    I did use as is above but it didn't work, so instead of using tag ${contents} And it works perfect ! – JRod Jul 07 '21 at 18:27