简体   繁体   中英

GitSCMExtension or GitSCM branch source configuration to fetch all/some additional remote branches in Jenkins multi-branch pipeline

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?

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$)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM