Guys,
I have a very strange problem... System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely is the message I get when trying to build a pull request. From either MASTER or a topic branch this all works perfectly.
2016-09-28T09:06:44.8095056Z ERROR [09/28/16 9:06:44:68] An unexpected error occurred:
2016-09-28T09:06:44.8095056Z System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.
2016-09-28T09:06:44.8095056Z at GitVersion.BranchConfigurationCalculator.InheritBranchConfiguration(Boolean onlyEvaluateTrackedBranches, IRepository repository, Commit currentCommit, Branch currentBranch, KeyValuePair`2 keyValuePair, BranchConfig branchConfiguration, Config config, IList`1 excludedInheritBranches)
2016-09-28T09:06:44.8095056Z at GitVersion.BranchConfigurationCalculator.GetBranchConfiguration(Commit currentCommit, IRepository repository, Boolean onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList`1 excludedInheritBranches)
2016-09-28T09:06:44.8095056Z at GitVersion.GitVersionContext.CalculateEffectiveConfiguration()
2016-09-28T09:06:44.8095056Z at GitVersion.GitVersionContext..ctor(IRepository repository, Branch currentBranch, Config configuration, Boolean onlyEvaluateTrackedBranches, String commitId)
2016-09-28T09:06:44.8095056Z at GitVersion.ExecuteCore.<>c__DisplayClass6_0.<ExecuteInternal>b__0(IRepository repo)
2016-09-28T09:06:44.8095056Z at GitVersion.GitPreparer.WithRepository[TResult](Func`2 action)
2016-09-28T09:06:44.8095056Z at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig)
2016-09-28T09:06:44.8095056Z at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
2016-09-28T09:06:44.8095056Z at GitVersion.Program.VerifyArgumentsAndRun()
Why might this be happening?
I have attached the full log and you can see it finds tags and lists the graph...
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDeployment
continuous-delivery-fallback-tag: ''
branches:
master:
mode: ContinuousDeployment
tag: ''
ignore:
sha: []
@MrHinsh: This looks like a duplicate of #912. Can you please peek at it and see if there's anything in there that can help? Also, if this is a duplicate, please close and continue the discussion in #912. :smile:
@MrHinsh See #993 for a workaround by adding an additional git fetch task to the build pipeline
Looks like this is the same issue as #993 and I am closing it here. You can also find more info at #912
I found in bitbucket that when it does a clone passing branch as command line arg, git clone result does not create neither master or develop branch and thus GitVersion is unable to find local branch.
In that case, I tweaked GitVersion file to accept remote branch as valid develop/master branch.
This code is my config:
mode: ContinuousDeployment
branches:
master:
regex: (^master$|^origin\/master$)
develop:
regex: (^dev(elop)?(ment)?$|^origin\/dev(elop)?(ment)?$)
This solved the issue in question.
This solved the issue in question.
thanks for this! i would've never checked default configuration because of the error message below
System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.
in my case the jenkins git-plugin did fetch all remote refs, it just did not create local branches tracking remote ones. I figured this should've been sufficient, given the above error message.. after the update to the regex outlined above, it is. Maybe this should be the actual default configuration unless i'm missing something ( and i may be .. )
Maybe this should be the actual default configuration
Yep, indeed it seems like it should. A PR changing the default regex and adding a new test for origin/master would be warmly welcomed. 馃檹
On second thought.. can you think of no use case where someone would depend on these regex values being what they are, by default? Additionally, what of remotes not named origin ? What if the regular expression ( (^master$|^origin\/master$) as above or even (^master$|^.*\/master$) ) returns multiple refs?
Maybe this is as simple as the exception message not assuming any kind of particular configuration and just guiding the user towards the config keys that were used to draw this conclusion, e.g. Could not find a 'develop' or 'master' branch, verify develop.regex and master.regex configuration values ?
Those are good points, @andlaz. But I think we can base GitVersion's assumptions on Git's defaults, which is to name the default branch master or main and the clone remote origin. Hard coding those defaults in GitVersion is therefore fine, imho. It should also be unnecessary to have a local tracking branch, since the branch references provided by origin are exactly the same, only placed differently.
Most helpful comment
I found in bitbucket that when it does a clone passing branch as command line arg, git clone result does not create neither master or develop branch and thus GitVersion is unable to find local branch.
In that case, I tweaked GitVersion file to accept remote branch as valid develop/master branch.
This code is my config:
This solved the issue in question.