GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

Using Mainline mode, patch is being increased oddly on Jenkins

Open AuroraBrignola opened this issue 9 years ago • 7 comments

I am using Jenkins for my CICD and every time I commit a fix, on the build server the versioning starts from x.y.1 and only increases to the next odd number, so to 3 and then to 5, skipping all the even numbers. But when I run gitversion locally, for the same project, the versioning is correct. Also, the minor increment starts from x.y.1 not x.y.0 on the build server, but locally starts from 0.

This is my yml:

mode: Mainline
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatchTag
tag-prefix: '[vV]'
major-version-bump-message: '.*BREAKING CHANGE:.*?'
minor-version-bump-message: '(?i)feat(\(.+\))?:'
patch-version-bump-message: '(?i)fix(\(.+\))?:'
no-bump-message: '^((?!.*BREAKING CHANGE|fix|feat).)*$|fix\s*?(\(\))|feat\s*?(\(\))'
legacy-semver-padding: 4
build-metadata-padding: 4
commits-since-version-source-padding: 4
commit-message-incrementing: disabled
branches: {}
ignore:
  sha: []

Any thoughts?

AuroraBrignola avatar Nov 06 '17 11:11 AuroraBrignola

How does it behave if you delete GitVersion.yml?

asbjornu avatar Nov 06 '17 13:11 asbjornu

@asbjornu after deleting the yml and writing the commit messages using the default structure (+semver: breaking|feat|fix), it seem to be working fine on the build server, but it's not working locally anymore..

AuroraBrignola avatar Nov 06 '17 13:11 AuroraBrignola

@asbjornu

The source of this behavior is because by default Jenkins will get origin/master as a local branch called origin/master

This means the code in the MainlineVersionCalculator will increment the patch because it thinks that it isn't master and the last commit wasn't a merge :

https://github.com/GitTools/GitVersion/blob/master/src/GitVersionCore/VersionCalculation/MainlineVersionCalculator.cs#L67

We worked around this by making Jenkins checkout to a local branch name called master.

ben3005 avatar Nov 09 '17 14:11 ben3005

Aha, that explains it. Thanks for figuring that out, @ben3005. Would you be interested in submitting a PR that fixes the comparison? I believe we compare against different variations of master elsewhere, so that comparison should probably be moved to an extension method or similar so we do it the same way everywhere.

asbjornu avatar Nov 09 '17 19:11 asbjornu

Hi all,

I've got this problem today. Is there any update or workaround about this issue ? :(

HotdogWang avatar Feb 11 '19 15:02 HotdogWang

@HotdogWang: Sorry, we need a PR to fix it. None has been provided so far and I don't have time to invest in fixing this as of now.

asbjornu avatar Feb 12 '19 10:02 asbjornu

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 29 '19 06:06 stale[bot]