简体   繁体   English

如何让TeamCity更新指定文件中的构建版本号?

[英]How to have TeamCity update the build version number in a specified file?

Does anyone know of an easy way to show the build version number in an HTML/JavaScript project that uses AMD? 有没有人知道在使用AMD的HTML / JavaScript项目中显示构建版本号的简单方法?

The version number is generated by TeamCity as part of the build process. 版本号由TeamCity生成,作为构建过程的一部分。

Here is what I mean in more details: 这是我的意思更详细:

One of my js files (eg showVersion.js) has a line like this: 我的一个js文件(例如showVersion.js)有这样一行:

  alert('Build version: __build_ver_placeholder__ ');

Ideally, after TeamCity completes the build, it will plug in the actual version number for the place-holder. 理想情况下,在TeamCity完成构建之后,它将插入占位符的实际版本号。 And the line above will become: 上面的行将成为:

  alert('Build version: 2.1.0 ');



That way, the user can know the build version number by clicking a button on an HTML page which calls the alert() function. 这样,用户可以通过单击调用alert()函数的HTML页面上的按钮来了解构建版本号。

Any idea will be greatly appreciated. 任何想法将不胜感激。 Thanks. 谢谢。

You can simply add PowerShell build step containing the following code: 您只需添加包含以下代码的PowerShell构建步骤:

(Get-Content "showVersion.js") 
| Foreach { $_ -Replace "__build_ver_placeholder__", "%build.number%" } 
| Set-Content "showVersion.js";

%build.number% variable will be replaced by TeamCity during the build 在构建期间, %build.number%变量将被TeamCity替换

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

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