TeamCity:VCS(Subversion)にアーティファクトのファイルバージョンをラベル付けする
-
22-07-2019 - |
質問
SVNでファイルのバージョンを使用してラベル(タグ)を作成します。
すでに、ビルドによって生成されたメイン実行可能ファイルのファイルバージョンを取得することにより、アーティファクトの名前を変更しています。例:MyInstaller-1.2.3.1.exe
。次に、SVNに/tags/1.2.3.1
というタグを作成します。ラベル付けパターンにそのようなことを設定する方法が見つかりませんでした。
現在、私のラベルは<!> quot;%system.build.number%<!> quot;
これを行う方法についてのアイデアはありますか?
TeamCity Professionalバージョン4.5.3(ビルド9035)を使用しています
解決
誰かが言ったように、ビルドスクリプトの実行中にビルド番号を出力することができ、teamcityはその出力を使用してビルドにラベルを付けます。たとえば、AssemblyInfo.csに入れたのと同じバージョンでビルドにラベルを付けます。そのバージョンの一部(メジャー、マイナー)は実際には既にファイル内にあり、他の部分(ビルド、リビジョン)はビルド中に追加されます。
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>
ビルド中にバージョンを出力するだけで、形式は##teamcity[buildNumber '<buildnum>']
他のヒント
Antを使用している場合は、SVNAnt.jarを取得してこれ。
ラベル付けに関して私が見た慣例はmajor.minor.svn(およびCIを使用している場合は.build)です。
SVNリビジョン番号をTeamCityビルド番号に含めることができます。 Teamcityのビルド番号パターンには、ビルド番号パターンフィールドで{build.vcs.number.1}のようなものを使用します。
その後、ビルド番号には実際のSVNリビジョン番号が含まれ、ラベル付けパターン%system.build.number%にも含まれます。
これが役立つことを願って、 KIR