如何让TeamCity更新指定文件中的构建版本号? [英] How to have TeamCity update the build version number in a specified file?
问题描述
有没有人知道在使用AMD的HTML / JavaScript项目中显示构建版本号的简单方法?
Does anyone know of an easy way to show the build version number in an HTML/JavaScript project that uses AMD?
版本号由TeamCity生成构建过程。
The version number is generated by TeamCity as part of the build process.
以下是我的详细信息:
Here is what I mean in more details:
我的一个js文件(例如showVersion.js)有这样的一行:
One of my js files (e.g. showVersion.js) has a line like this:
alert('Build version: __build_ver_placeholder__ ');
理想情况下,在TeamCity完成构建后,它会插入占位符的实际版本号。
上面的行将成为:
Ideally, after TeamCity completes the build, it will plug in the actual version number for the place-holder. And the line above will become:
alert('Build version: 2.1.0 ');
这样,用户就可以知道构建通过单击调用alert()函数的HTML页面上的按钮来显示版本号。
That way, the user can know the build version number by clicking a button on an HTML page which calls the alert() function.
任何想法都将不胜感激。谢谢。
Any idea will be greatly appreciated. Thanks.
推荐答案
您只需添加包含以下代码的PowerShell构建步骤:
You can simply add PowerShell build step containing the following code:
(Get-Content "showVersion.js")
| Foreach { $_ -Replace "__build_ver_placeholder__", "%build.number%" }
| Set-Content "showVersion.js";
%build.number%变量将在构建期间被TeamCity取代
%build.number% variable will be replaced by TeamCity during the build
这篇关于如何让TeamCity更新指定文件中的构建版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!