Skip to content

3.6.2: TFS15RC1: An unexpected error occurred: System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely. #996

Closed

Description

@nphmuller

Server: TFS15RC1
Agent version: 2.103.1
GitVersion version: 3.6.2

On TFS15RC1 it seems Microsoft changed the way in which Git retrieves it's data, which causes at least pull request builds to fail when calling the GitVersion task, if the repository has not fetched the master and/or dev branch before.

Repro:

  • Create a build definition and add at least the GitVersion task. I had a release branch as default in the build definition (releases/3.0), but I don't think this matters.
  • Select this build definition in the branch policy in 'Automatically build pull requests'.
  • Create a pull request and the GitVersion build task fails. (See log output below).

Optional:

  • If you want the repro to keep working (even after manually fetching the dev and/or master branch) add the Build.Clean=source variable to the build definition.

If I log in to the build agent's source directory and manually fetch the dev and/or master branch (or all with git fetch -all), the build will work.

2016-08-10T10:32:19.5020593Z ERROR [08/10/16 12:32:19:39] An unexpected error occurred:
2016-08-10T10:32:19.5020593Z System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.
2016-08-10T10:32:19.5020593Z    at GitVersion.BranchConfigurationCalculator.InheritBranchConfiguration(Boolean onlyEvaluateTrackedBranches, IRepository repository, Commit currentCommit, Branch currentBranch, KeyValuePair`2 keyValuePair, BranchConfig branchConfiguration, Config config, IList`1 excludedInheritBranches)
2016-08-10T10:32:19.5020593Z    at GitVersion.BranchConfigurationCalculator.GetBranchConfiguration(Commit currentCommit, IRepository repository, Boolean onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList`1 excludedInheritBranches)
2016-08-10T10:32:19.5020593Z    at GitVersion.GitVersionContext.CalculateEffectiveConfiguration()
2016-08-10T10:32:19.5020593Z    at GitVersion.GitVersionContext..ctor(IRepository repository, Branch currentBranch, Config configuration, Boolean onlyEvaluateTrackedBranches, String commitId)
2016-08-10T10:32:19.5020593Z    at GitVersion.ExecuteCore.<>c__DisplayClass6_0.<ExecuteInternal>b__0(IRepository repo)
2016-08-10T10:32:19.5020593Z    at GitVersion.GitPreparer.WithRepository[TResult](Func`2 action)
2016-08-10T10:32:19.5020593Z    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig)
2016-08-10T10:32:19.5020593Z    at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
2016-08-10T10:32:19.5020593Z    at GitVersion.Program.VerifyArgumentsAndRun()

Activity

  1. nphmuller commented on Aug 10, 2016

    @nphmuller
    Author

    Here's the error on GitVersion v4.0.0-beta.2

    ERROR [08/10/16 12:50:29:06] An unexpected error occurred:
    System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.
       at GitVersion.BranchConfigurationCalculator.InheritBranchConfiguration(Boolean onlyEvaluateTrackedBranches, IRepository repository, Commit currentCommit, Branch currentBranch, KeyValuePair`2 keyValuePair, BranchConfig branchConfiguration, Config config, IList`1 excludedInheritBranches)
       at GitVersion.BranchConfigurationCalculator.GetBranchConfiguration(Commit currentCommit, IRepository repository, Boolean onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList`1 excludedInheritBranches)
       at GitVersion.GitVersionContext.CalculateEffectiveConfiguration()
       at GitVersion.GitVersionContext..ctor(IRepository repository, Branch currentBranch, Config configuration, Boolean onlyEvaluateTrackedBranches, String commitId)
       at GitVersion.GitVersionContext..ctor(IRepository repository, Config configuration, Boolean isForTrackingBranchOnly, String commitId)
       at GitVersion.ExecuteCore.<>c__DisplayClass6_0.<ExecuteInternal>b__0(IRepository repo)
       at GitVersion.GitPreparer.WithRepository[TResult](Func`2 action)
       at GitVersion.ExecuteCore.ExecuteInternal(String targetBranch, String commitId, GitPreparer gitPreparer, IBuildServer buildServer, Config overrideConfig)
       at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, StringcommitId, Config overrideConfig)
       at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
       at GitVersion.Program.VerifyArgumentsAndRun()
    
  2. pascalberger commented on Aug 10, 2016

    @pascalberger
    Member

    Does the workaround provided in #993 solves your issue?

  3. asbjornu commented on Aug 10, 2016

    @asbjornu
    Member

    This just occurred to me on Travis, so I don't think the problem is build server related.

  4. nphmuller commented on Aug 10, 2016

    @nphmuller
    Author

    Workaround works fine. Thought about using, but wasn't sure how to pass the access token.
    Thanks for helping out!

  5. JakeGinnivan commented on Aug 11, 2016

    @JakeGinnivan
    Contributor

    @asbjornu why is it cloning your fork:

    git clone --depth=50 --branch=feature/mkdocs-build https://github.com/asbjornu/GitVersion.git asbjornu/GitVersion

    Could that be the issue?

  6. JakeGinnivan commented on Aug 11, 2016

    @JakeGinnivan
    Contributor

    Going to close this one down, Will use the other issue to track, I will likely move this knowledge into GitVersion itself so it will throw if the OAuth token is not passed for PR's

  7. asbjornu commented on Aug 11, 2016

    @asbjornu
    Member

    @JakeGinnivan It's cloning my fork since this is my personal Travis project. I like to have Travis run the tests before I PR it against the GitTools repository. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions