简体   繁体   English

哈德森/詹金斯的速度插件?

[英]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? Jenkins / Hudson是否具有可调用诸如Velocity模板引擎之类的插件以允许将变量插值到一组模板中以生成文件的插件?

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. 我有一个html页面,每次执行构建时,都需要在适当的位置将$ {BUILD_NUMBER}插入其中。

You can try Groovy Plugin and exploit Groovy's Template Engine feature. 您可以尝试使用Groovy插件并利用Groovy的模板引擎功能。 Add a Groovy build step and pass ${BUILD_ID} and the path to your HTML template file as parameters. 添加一个Groovy构建步骤,并将$ {BUILD_ID}和HTML模板文件的路径作为参数传递。 In the build step itself write code that uses ${args[0]} , ${args[1]} to get the parameters, and then employs SimpleTemplateEngine to process. 在构建步骤中,自己编写使用${args[0]}${args[1]}获取参数的代码,然后使用SimpleTemplateEngine进行处理。

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. 我打算按照建议的方式去执行Groovy路线(这是一个好主意),但是我却利用了我的构建服务器在* Nix OS上的事实,而是编写了一行sed来使用Shell构建来完成这项工作。步。

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. 它只是用Jenkins / Hudson内部版本号替换文本中出现的任何文本: BUILD_NUMBER Quick, dirty, but works. 快速,肮脏,但是有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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