4
votes

I have configured my git repository in VSTS with the GitFlow repository.

I have a master branch with a dotnet core project, and a release branch called 'Release/1.0.0'. When I create a pull-request and merge the release/1.0.0 branch back to master, it does not increment it's version number to 1.0.0. Instead, it's increasing the version number from 0.1.0 (the base fallback) to 0.1.1.

Build log:

Calculating base versions
Fallback base version: 0.1.0 with commit count source xx
Git tag '0.1.0': 0.1.0 with commit count source xx
Base version used: Git tag '0.1.0': 0.1.0 with commit count source xx

However, the commit label is Merge branch Release/1.0.0 to master. And the branch being merged is tagged as 1.0.0.

I am using GitVersion default settings. I am using the GitVersion VSTS task.

This is the gitversion configuration:

assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDelivery
branches: {}
ignore:
  sha: []

What should i do to automatically set the version of the master branch to the versionnumber that is being merged?

Update: I found out what was going "wrong".

Releases were merged back as pull requests. This will set the commit message to Merge PR #### . However, the MergeMessageBaseVersionStrategy of gitversion can not handle this. If i merge the release back as a regular merge, the version number is increased.

1
Does the build is triggered for PR validation? And can you should the GitVersion.yml file and the setting for GitVersion task in your build definition? - Marina Liu
The master branch has a policy that code can only be added after completing a PR. After completion the build is triggered. I added the gitversion configuration - Richard Mosselveld
You can remove generated "Merged PR..." prefix before completing pull request. - Zabavsky

1 Answers

0
votes

You should add the GitVersion task in the CI build for master branch (or queue build after the PR is completed) instead of PR build validation.

Since the PR build validation is triggered before release/1.0.0 branch really merge into master, so Gitversion will detect the version from master branch (such as version in AssemblyInfo.cs file).

If you add the GitVersion task in CI build (after the release/1.0.0 branch merged into master branch), then Gitversion will detect the version major.minor.patch=1.0.0 from release/1.0.0 branch.