Configuring Build Number using source code Follow
Is there a way to have team city set the build number format using information from source code?
I would like to set my major / minor versions with the source code instead of constants in the build configuration.
Build Format: %env.MajorVersion%.%env.MinorVersion%.%build.vcs.number%.%build.counter%.
The VCS number and build counter work as expected. I want to however read in the major and minor version from the checked in code. I was able to create a build step that uses powershell to read in the major and minor version and I believe I am using the teamcity set parameter command correctly as I can confirm that the information changes in the parameters of the build. The problem is that the build number has already been set in team city and then I am modifying the variables afterwords.
Example of the powershell
[xml]$xmlData = Get-Content -Path Example_Build
$MajorV = $xmlData.Project.PropertyGroup.MajorVer
$MinorV = $xmlData.Project.PropertyGroup.MinorVer
$BuildV = "%build.counter%"
$RepositoryV = "%build.vcs.number%"
Write-Host "##teamcity[message text='Version = $MajorV.$MinorV.$RepositoryV.$BuildV']"
Write-Host "##teamcity[setParameter name='env.MajorVersion' value='$MajorV']"
Write-Host "##teamcity[setParameter name='env.MinorVersion' value='$MinorV']"
Write-Host "##teamcity[setParameter Name='build.number' value='$MajorV.$MinorV.$RepositoryV.$BuildV']"
Please sign in to leave a comment.
Hello!
Please consider using this service message instead:
Please let me know if this helps.