TeamCity: labeling VCS (Subversion) with an artifact's file version
Asked Answered
D

3

4

I want to create create a label (tag) in the SVN with a file's version.

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. Now I want to create a tag in the SVN called /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%"

Any idea about how to do this?

I'm using TeamCity Professional Version 4.5.3 (build 9035)

Discouragement answered 24/6, 2009 at 21:41 Comment(0)
P
7

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. For example, I label my build with the same version that I put into AssemblyInfo.cs. Part of that version (Major, Minor) is actually in the file already, the other part (Build, Revision) gets added during the build.

From my msbuild script:

<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>']

Pameliapamelina answered 2/2, 2010 at 18:48 Comment(1)
I found documentation for the ##teamcity Service Message hereEvenfall
D
0

If you're using Ant, maybe you should get SVNAnt.jar and try this.

The convention that I've seen for labeling is major.minor.svn (and .build if you're using CI).

Durtschi answered 24/6, 2009 at 21:54 Comment(4)
actually I'm using sln2008 runner from TeamCity and also my labelling done by TeamCity as well. All other custom build scripts "shamefully" written as Post-Build script in the VS.NET project.Discouragement
What I want really make a tag indicates the actual release version, the version which people downloading and using. I thought it'd be the easiest way to mark it.Discouragement
Subversion won't read your mind about major.minor release. You should build that into your tag name. That'll be enough of a clue for people, in my opinion.Durtschi
Normally TeamCity supports variables but I couldn't find a way to put my own variable, I think that's the only way to tell it to TeamCity. Otherwise as you said I need to do it manually in my post-build scripts.Discouragement
G
0

You can include SVN revision number to your TeamCity build number. For your build number pattern in Teamcity, use something like {build.vcs.number.1} in the build number pattern field.

After that build number will contain actual SVN revision number, and your labeling pattern %system.build.number% will contain it as well.

Hope this helps, KIR

Gensler answered 24/8, 2009 at 9:26 Comment(2)
I'm trying to label SVN by using the version of an artifact file.Discouragement
You can set build number from your build script and pass it to the server. See TeamCity docs for build script interaction with TeamCity.Gensler

© 2022 - 2024 — McMap. All rights reserved.