How to skip build counter in TeamCity

I am trying to follow the recommendations of this article , which describes the best practices of NuGet and SemVer.

Point # 3 states that I should "Use leading zeros in the numeric suffix to automatically increase the preliminary values," but I'm struggling to determine how I can zero-fill the build.counter parameter in TeamCity to get 0025 25 instead.

Does anyone have a mechanism for this?

+5
source share
2 answers

If I were you, I would use GitVersion . It includes the ability to use the LegacySemVerPadded version of the generated version number. There are various other alternatives to the generated version number .

For this there is a Meta Runner TeamCity for here .

GitVersion does the work of calculating a new semantic version number for you based on the current state of your repository.

Otherwise, do the work elsewhere in PowerShell, and then use TeamCity service messages to change the build number in TeamCity. Here you can find the PowerShell module.

This provides some helper functions to do just that.

+2
source

You can write powershell script as:

 function Update-BuildNumber([string]$buildNumber) { $VersionComponents = $buildNumber.Split(".") $buildNumber = "" foreach($VersionComponent in $VersionComponents) { $index = [array]::IndexOf($VersionComponents, $VersionComponent) if (($index + 1) -eq $VersionComponents.Count) { $buildNumber += "00" + $VersionComponent } else { $buildNumber += $VersionComponent + "." } } Write-Output "##teamcity[buildNumber '$buildNumber']" } 

And name it from the Teamcity build step and pass the %build.number% parameter something like:

 Update-BuildNumber -buildNumber %build.number% 
+4
source

Source: https://habr.com/ru/post/1202876/


All Articles