How can I label my build with revision number and not the GUID (in TeamCity)?

后端 未结 6 597
忘了有多久
忘了有多久 2021-01-30 11:15

I am trying to do \"continuous integration\" with TeamCity. I would like to label my builds in a incremental way and the GUID provided by the VCS is not as usefull as a simple i

6条回答
  •  旧巷少年郎
    2021-01-30 11:53

    When providing your build number with numeral mercurial revision, you must be aware, that those numbers are clone-specific and can differ from clone to clone.

    In our project we had the same issue. We're using TeamCity 7.1.1. We solved it in the following way:

    1. Add Command line build step to your configuration.
    2. Make this build step run first.
    3. In the build step properties select "Run: 'Executable with parameters'"
    4. Add the following text to Command Executable:

    for /f %%i in ('hg id -n') do echo ##teamcity[buildNumber '%%i']

     Save changes.
    

    You can also use previously generated build number when performing step 3.

    Example:

    for /f %%i in ('hg id -n') do echo ##teamcity[buildNumber '%system.build.number%.%%i']
    

    You can use this to make build counter present in your build number.

    Read this to get more information!

    Remember that teamcity compiles configurations build number before build starts and the correct build number will appear only after your build step will finish its job. That's why, in some cases (f.e. inserting your mercurial revision into artifact's name) you should define build number's value in preceding configuration and refer to it.

    Example:

    %dep.bt82.build.number%
    

    Read this to get more information!

提交回复
热议问题