简体   繁体   中英

How to read string from file using Groovy in QuickBuild

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:
I know that it supports Groovy, MVEL and OGNL languages but I'm not familiar with any of them.

Thanks in advance.

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 :)

稍微短一点的版本,只读取第一行(不对EOL字符做任何假设):

${groovy: str = new File("[PATH_TO]/file.txt").readLines()[0] }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM