最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to have TeamCity update the build version number in a specified file? - Stack Overflow

programmeradmin0浏览0评论

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 pletes the build, it will plug in the actual version number for the place-holder. And the line above will bee:

  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.

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 pletes the build, it will plug in the actual version number for the place-holder. And the line above will bee:

  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.

Share Improve this question asked Feb 7, 2014 at 7:01 user3239076user3239076 853 bronze badges 2
  • Is version no an environment variable? – Adarsh Shah Commented Feb 8, 2014 at 14:08
  • You have to write a script to update your files. – Aleš Roubíček Commented Feb 10, 2014 at 8:08
Add a ment  | 

1 Answer 1

Reset to default 11

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

发布评论

评论列表(0)

  1. 暂无评论