We use Jenkins CI and have recently been experimenting with GitVersion for automatically generating SemVer version numbers. However, when combining GitVersion with Multibranch Pipeline jobs (which automatically build branches and PRs for a given Git repository), we've run into GitVersion's limitation of only one remote (as enforced by its NormalizeGitDirectory function). The specific error we encounter is:
System.ComponentModel.WarningException: 2 remote(s) have been detected. When being run on a build server, the Git repository is expected to bear one (and no more than one) remote.
The only solution we've found (as blogged here) is to manually remove the "origin1" remote after the SCM checkout, prior to any build steps that would invoke GitVersion, like so:
bat 'git remote remove origin1'
This works but feels very much like a hack, and would likely not work with any fork-sourced PRs.
Is there a better solution out there?