Skip to content

GitVersion fails to pull a dymanic repository when on TeamCity #611

@RichiCoder1

Description

@RichiCoder1

Here's the error message:

C:\Source\core [release/2.2.0 +1 ~4 -0 !]> .\tools\GitVersion.CommandLine\tools\GitVersion.exe /url "******" /u ******* /p ********* /b "refs/heads/release/2.2.0" /c ea0f3605343b5703b98815e8f34c04dda91f9564 /output json
INFO [08/25/15 16:14:47:55] Working directory: C:\Source\core
INFO [08/25/15 16:14:47:56] Applicable build agent found: 'TeamCity'.
ERROR [08/25/15 16:14:47:56] An unexpected error occurred:
System.Exception: Dynamic Git repositories must have a target branch (/b)
   at GitVersion.GitPreparer.CreateDynamicRepository(String targetPath, Authentication authentication, String repositoryUrl, String targetBranch, Boolean noFetch)
   at GitVersion.GitPreparer.Initialise(Boolean normaliseGitDirectory, String currentBranch)
   at GitVersion.ExecuteCore.ExecuteGitVersion(IFileSystem fileSystem, String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId)
   at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
   at GitVersion.Program.VerifyArgumentsAndRun()

Source at fault: https://github.com/GitTools/GitVersion/blob/master/src/GitVersionCore/ExecuteCore.cs#L20

TeamCity returns string.Empty which cases currentBranch ?? targetBranch to evaluate to string.Empty. Can be fixed by instead writing:

gitPreparer.Initialise(buildServer != null, string.IsNullOrWhiteSpace(currentBranch) ? targetBranch : currentBranch); 

This is a somewhat critical bug as it does block using 3.1.0 at all, though we're experimenting with a work around where we kill $env.TEAMCITY_VERSION for the lifetime of the git version run.

EDIT: Workaround worked :). World not as ending.

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