I've been trying to find the branch source configuration to fetch at least the develop and master remote branches, in addition to the branch the job is running for, with zero success.

My use case is determining version from git ref names and commit messages with GitVersion. So far, the only workaround i've found is cumbersome and non-portable, as it requires credentials to be provided to the git cli, when not running against a local ( file:// ) repo.

sh "git fetch origin master:master"
sh "git fetch origin develop:develop"

will i have to write a custom GitSCMExtension do get this behavior?

1

There are 1 answers

0
pgn On BEST ANSWER

Looks like refs for remote branches ( origin/{branch} ) are in fact fetched, only no matching local tracking branches ( origin/{branch} -> {branch} ) are created, which throws GitVersion off. Seems like the error message it produces directly contradicts this default configuration:

System.InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.

Found the solution at https://github.com/GitTools/GitVersion/issues/1049#issuecomment-585878737

which was to configure GitVersion to actually consider /origin/master and /origin/develop

  develop:
    # (..)
    regex: (^dev(elop)?(ment)?$|^origin\/dev(elop)?(ment)?$)
  master:
    # (..)
    regex: (^master$|^origin\/master$)