GitVersion at Jennkins Multibranch Pipeline

We use Jenkins CI and have recently experimented with GitVersion to automatically create SemVer version numbers. However, when combining GitVersion with the Multibranch Pipeline tasks (which automatically create branches and PRs for this Git repository), we encountered the restriction of GitVersion to only one remote (in accordance with its NormalizeGitDirectory ). The specific error we are facing is:

System.ComponentModel.WarningException: deleted (deleted) 2 detected. When launched on the build server, the Git repository is expected to have one (and no more than one) remote.

The only solution we found (as described in the blog here ) is to manually remove the remote control "origin1" after checking SCM, before any build steps that will invoke GitVersion, for example:

bat 'git remote remove origin1' 

This works, but it is very similar to a hack, and most likely it will not work with any PR files using fork.

Is there a better solution?

+5
source share
1 answer

It seems that when requesting traction, two remote controls are required to track the build result for both (at least I did not return the results to PR when the remote was removed)

Using the current beta version 4.0.13 (and .12 beta), I tried to solve it by pulling directly, but there is an error that affects the calculation of the current version when used directly ( https://github.com/GitTools/GitVersion/issues / 1390 )

My current workaround is to remove the front pool before:

 def remotes = bat(script: "@call git remote show", returnStdout: true).trim().readLines() def hasUpstream = remotes.any { it == "upstream" } def upstreamURL if (hasUpstream) { echo "Remote 'upstream' detected -- ${env.BRANCH_NAME} is pull request, removing remote for further processing" upstreamURL = bat(script: "@call git remote get-url upstream", returnStdout: true).trim() bat "git remote remove upstream" } 

then do:

 def command = "@call ${BuildInfo.GitVersion.Run} /updateassemblyinfo /ensureassemblyinfo /nofetch /verbosity debug" def output = bat(script: command, returnStdout: true).trim() 

and add it back:

 if (hasUpstream) { echo "Restoring 'upstream' remote using url: ${upstreamURL}" bat "git remote add -t master --tags upstream ${upstreamURL}" } 
+1
source

All Articles