Saving final build version in TeamCity
I am using file content replacer Build Feature to change the AssemblyVersion and AssemblyFileVersion but I do not see any option to save the final version in TeamCity so that I can use it somewhere else down the build step.
Any pointers on how to achieve this is really appreciated.
Please sign in to leave a comment.
Hi Ibrahim,
If you are using the content replacer for that, you probably have (or should have) the "final" version as a build parameter, that then you assign to the fields. By using it as a parameter, you could use in any build step on that configuration, and any other configurations that have this one as a dependency.
More information on parameters here: https://confluence.jetbrains.com/display/TCD10/Configuring+Build+Parameters
@Denis From the UI it does not seem that its possible to save the build version that I have replaced using file content replacer. So, what I am currently doing now is I have written a PS script that does the replacement in AssemblyInfo.cs file and updates a Configuration parameter but the updated version is only available down the build steps and not permanently changed in TeamCity.
Hi Ibrahim,
sorry, I think I misunderstood you. With "final version" you mean the value used *after* the content replacer happens?
Yes. The resultant assmebly version in my AssemblyInfo file after content replacer has done its job.
Hi Ibrahim,
ok, I think that now I have a better grasp on what your issue is. You already use a parameter, some "%new_value%", and change this value in your script, so you want it to be updated permanently in teamcity.
Updating it through the build, as you have seen, only changes it in scope of the build. In order to change it permanently, we have a feature request in our tracker to allow for it. Please watch, vote and add any comment you see fit to it here: https://youtrack.jetbrains.com/issue/TW-31309
In the meantime, you can do a REST API request to have the property changed wherever it's defined. How to do it is described in a comment on the issue.
Hope this helps.
@Denis Lapuente Thanks for informing that there is already a feature in works for this. I am currently making an API request to update a Configuration Parameter %Version% that is bound to General Settings > Build number format. The problem it seems is TeamCity shows the Build number in the project home at the very beginning and so the parameter update after the build step is not reflected. Therefore, from the Project home I am always seeing the previous value of %Version% parameter.
Hi Ibrahim,
There is two different "instances" of the "%Version%" parameter. One is the instance on the build configuration itself, which is the one you update. The other one is in the build itself. The one reported in the overview is the one that is in the build, so additionally to updating the one in the build configuration via the REST API, you need to set the "build.number" parameter to the value once you have calculated it. If you configure build number to be "%version%" it will be assigned upon build queuing, so if you recalculate %version% through the build process, you need to assign it to build.number as well.
If you are already assigning build.number but it doesn't reflect, then that's a slighly different problem that we might need to look at.