简体   繁体   English

TeamCity:使用工件的文件版本标记VCS(Subversion)

[英]TeamCity: labeling VCS (Subversion) with an artifact's file version

I want to create create a label (tag) in the SVN with a file's version. 我想在SVN中创建一个带有文件版本的标签(标签)。

I'm already renaming the artifact by getting the file version of the main executable produced by the build. 我已经通过获取构建生成的主要可执行文件的文件版本来重命名工件。 Such as: MyInstaller-1.2.3.1.exe . 如: MyInstaller-1.2.3.1.exe Now I want to create a tag in the SVN called /tags/1.2.3.1 . 现在我想在SVN中创建一个名为/tags/1.2.3.1的标签。 I couldn't find a way to set such a thing in the labeling pattern. 我找不到在标签模式中设置这样的东西的方法。

Currently my labeling is just "%system.build.number%" 目前我的标签只是“%system.build.number%”

Any idea about how to do this? 有关如何做到这一点的任何想法?

I'm using TeamCity Professional Version 4.5.3 (build 9035) 我正在使用TeamCity Professional Version 4.5.3(build 9035)

As someone mentioned, you can output the build number during the execution of the build script, and teamcity will use that output to label the build. 正如有人提到的,您可以在构建脚本执行期间输出构建号,teamcity将使用该输出来标记构建。 For example, I label my build with the same version that I put into AssemblyInfo.cs. 例如,我使用与AssemblyInfo.cs相同的版本标记我的构建。 Part of that version (Major, Minor) is actually in the file already, the other part (Build, Revision) gets added during the build. 该版本的一部分(Major,Minor)实际上已经在文件中,另一部分(Build,Revision)在构建期间被添加。

From my msbuild script: 从我的msbuild脚本:

<Target Name="Setup">
    <!-- Version.txt contains the major and minor version numbers, 
         The build number and revision come from environment variables
         in the next step -->
    <Version VersionFile="Version.txt" BuildType="None" RevisionType="None">
        <Output TaskParameter="Major" PropertyName="Major" />
        <Output TaskParameter="Minor" PropertyName="Minor" />
    </Version>

    <!-- If you want to build a release without going through the build
         server, you should define the following 2 environment variables
         when running this build script -->

    <!-- BUILD_NUMBER environment variable supplied by the build server -->
    <CreateProperty
        Value="$(BUILD_NUMBER)">
        <Output
            TaskParameter="Value"
            PropertyName="Build" />
    </CreateProperty>

    <!-- BUILD_VCS_NUMBER environment variable supplied by the build server -->
    <CreateProperty
        Value="$(BUILD_VCS_NUMBER)">
        <Output
            TaskParameter="Value"
            PropertyName="Revision" />
    </CreateProperty>       

    <AssemblyInfo CodeLanguage="CS"  
        OutputFile="Properties\VersionInfo.cs" 
        AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)" 
        AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)" />

    <!-- Tell the build server what our actual build number is -->
    <Message Text="##teamcity[buildNumber '$(Major).$(Minor).$(Build).$(Revision)']" />
</Target>

you just output the version during the build the format is ##teamcity[buildNumber '<buildnum>'] 您只需在构建期间输出版本格式为##teamcity[buildNumber '<buildnum>']

If you're using Ant, maybe you should get SVNAnt.jar and try this . 如果你正在使用Ant,也许你应该得到SVNAnt.jar并试试这个

The convention that I've seen for labeling is major.minor.svn (and .build if you're using CI). 我看到的用于标记的约定是major.minor.svn(和.build,如果你正在使用CI)。

You can include SVN revision number to your TeamCity build number. 您可以将SVN修订号包含在TeamCity内部版本号中。 For your build number pattern in Teamcity, use something like {build.vcs.number.1} in the build number pattern field. 对于Teamcity中的构建号码模式,请在构建号码模式字段中使用类似{build.vcs.number.1}的内容。

After that build number will contain actual SVN revision number, and your labeling pattern %system.build.number% will contain it as well. 在该构建号之后将包含实际的SVN修订号,并且您的标签模式%system.build.number%也将包含它。

Hope this helps, KIR 希望这有帮助,KIR

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

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