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

微笑、不失礼 提交于 2019-12-12 10:56:57

问题


Does anyone know of an easy way to show the build version number in an HTML/JavaScript project that uses AMD?

The version number is generated by TeamCity as part of the build process.

Here is what I mean in more details:

One of my js files (e.g. showVersion.js) has a line like this:

  alert('Build version: __build_ver_placeholder__ ');

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 ');



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.


回答1:


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% variable will be replaced by TeamCity during the build



来源:https://stackoverflow.com/questions/21621286/how-to-have-teamcity-update-the-build-version-number-in-a-specified-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!