How to make the Gitversion VSTS increment release number on master?

元气小坏坏 提交于 2021-01-03 05:34:27

问题


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:


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.



来源:https://stackoverflow.com/questions/47062391/how-to-make-the-gitversion-vsts-increment-release-number-on-master

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!