How is BuildID Macro is incremented in TFS Builds, and how can I make it go like ++?

白昼怎懂夜的黑 提交于 2019-12-10 20:02:37

问题


I'm working on a project being compiled over a TFS server. The build number format (in the process tab of the build settings) is defined as $(BuildDefinitionName)_$(BuildID). What I can't figure out is how the $(BuildID) is incremented. If I queue, say two builds, within the same hour, it will usually increase by one, but not always.

If it's been ~one week since the last build it might increment by 20 or 40. I haven't figured any pattern yet.

But my real question would be : how can I make it increase by one at each build.


回答1:


$(BuildID) is used for the whole team project collection. I assume you have multiple team projects in your collection.

So every build triggerd increments this ID by one (It's basically the primary key of the respective build in the TFS DB).




回答2:


I suspect that your build number is incrementing by 1 each build, but you're only looking at the list of your own builds. Other people are triggering builds (possibly including the build server, if CI is enabled), and the count is only separate per build definition, not per user.

That's why a longer delay results in a bigger increment: if you're waiting a week, more builds have been run by other checkins/developers.

If you look at the list of all builds, instead of "My Builds" as in your screenshot, you'd likely see a number that increments by 1 each time.

You can't change this as simply as you hope, because if you make the number "per-user" you'd end up with multiple builds with the same ID. It's possible to override the part of the build script that creates the build number to include your username and a number - which means your build ID would increment by 1 each time, but each user would have a different build name. (You'd have builds DEV_JOHN_123/DEV_BOB_123 instead of just DEV_123/DEV_124).




回答3:


You should use $(Rev) script to increment by one number. $(Rev) can only be used at the end of your build name string.

Eg. $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r) build number format would produce for three consecutive check-ins on the same day (if you have continuous integration set):

  1. MyProject_20130828.1
  2. MyProject_20130828.2
  3. MyProject_20130828.3

As you can see the last part was autoincremented on each check-in.



来源:https://stackoverflow.com/questions/15502010/how-is-buildid-macro-is-incremented-in-tfs-builds-and-how-can-i-make-it-go-like

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