0

I am new to QuickBuild.

I have a lot of different versions stored in text files.
To start the build process, I need to retrieve the versions from the text files and pass them to a shell script.

My question is: How do I read the contents of a file using the QuickBuild environment?
I know that it supports Groovy, MVEL and OGNL languages but I'm not familiar with any of them.

Thanks in advance.

pczeus
  • 7,709
  • 4
  • 36
  • 51
Cyril
  • 159
  • 3
  • 16

2 Answers2

1

I found the solution :)

${groovy: str = new java.io.File("[PATH_TO]/file.txt").text}

or

${groovy: str = new java.io.File("[PATH_TO]/file.txt").text
str.split("[\\r\\n]")[0] } 

to read the first line only.

Thanks to me :)

Dónal
  • 185,044
  • 174
  • 569
  • 824
Cyril
  • 159
  • 3
  • 16
0

A slightly shorter version for reading only the first line (which doesn't make any assumption about the EOL character):

${groovy: str = new File("[PATH_TO]/file.txt").readLines()[0] }
Dónal
  • 185,044
  • 174
  • 569
  • 824