简体   繁体   中英

Velocity Plugin for Hudson/Jenkins?

Does Jenkins/Hudson have a plugin which invokes something like a Velocity template engine to allows the interpolation of variables into a set of templates in order to generate files?

I have an html page which needs to have the ${BUILD_NUMBER} inserted into it at the proper place each time I do a build.

You can try Groovy Plugin and exploit Groovy's Template Engine feature. Add a Groovy build step and pass ${BUILD_ID} and the path to your HTML template file as parameters. In the build step itself write code that uses ${args[0]} , ${args[1]} to get the parameters, and then employs SimpleTemplateEngine to process.

I was going to go the Groovy route as suggested (which is a good idea), however instead I took advantage of the fact my build server is on a *Nix OS and instead wrote a line of sed to do the job using the Shell build step.

sed -e '/BUILD_NUMBER/${BUILD_NUMBER}/' ${WORKSPACE}/index.html.template > ${WORKSPACE}/index.html

It just replaces any occurrence of the text: BUILD_NUMBER inside my template file with the Jenkins/Hudson build number. Quick, dirty, but works.

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