TeamCity to read and update version number from version file

We use TeamCity as a CI server, and we thought about how to implement the method for the version of our safe versions (i.e., the minimum possibilities for human error), but it also requires the least effort. So far, the most logical is the following:

  • Create a version file (or use assemblyinfo.cs). The version information will be in the format .... This file will be checked in my VCS.
  • Run the TeamCity build.
  • TeamCity reads the version file from step 1, selects each individual number and sets the appropriate TeamCity build options (so I can use them later for things like creating nuget packages and labeling them).
  • TeamCity automatically increments the final build count.
  • TeamCity saves new version information back to the version file (with updated "build counter")
  • TeamCity launches all the other steps of my build, creates files, runs unit tests, installs the correct build versions, etc.
  • TeamCity finally checks file back to VCS

We believe that the advantage in doing so is that we need to fix the old version, then the version number will be correct, and TeamCity can simply work with the old version file and increase the build count as usual. This makes the assumption that we are updating our major / minor / version fixes correctly. This, I hope, will work well with the high-speed version of TeamCity 7.1, which allows you to choose which branch to build through the custom build dialog box.

From what I have read so far, such operations should be possible in TeamCity, but we are looking for the simplest root to get this fix, since we are only an outfit for two people, and we cannot afford to invest large amounts of time becoming experts in Nantes or in PowerShell just to find that he might not do what we want.

So, I come to summarize my questions as follows:

  • Is it possible?
  • If so, what is the best tool to use, given my limited experience with Nant, powershell, etc. (that is, one that learns the fastest from someone whose command line and script has experience with simple DOS operations and a bit of VBScript)

Any help is greatly appreciated.

+6
source share
1 answer

For your first question: yes, maybe:

  • Add .git (.svn, .hg etc) to VCS rules
  • Read the version number in your build script in teamcity (runner runter) in your favorite scripting language and find it.
  • Set build number through interaction protocol
  • Update build number in version file in your favorite scripting language
  • Complete assembly steps
  • Commit and click, you can, because you already have a .git (.svn, .hg, etc.) directory in dir in the last step.

Sorry, but I can not answer your second question, because I do not know any suitable tools for windows. On linux, I would use bash.

+9
source

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


All Articles