简体   繁体   中英

Write to file with Jenkins and Groovy

When running my Jenkins build i need to update the contents of a file with a version number in this case. I have come across a plugin called text-file-operations but rather than write a whole new file I thought it would be better to update.

In this example I have a podspec file located in the root of the project which just needs a version number updated with a variable I have created earlier in the process.

spec.version               = '13.4.0'

I just need to convert that to

spec.version               = "${VERSION_NUMBER}"

Is there a way to do this ?

Is this what you want then?

Groovy + how to append text in file ( new line )

f = new File('<filename>')
f.append("spec.version               = ${VERSION_NUMBER}\n")

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