I'm currently setting up GitLab CI/CD. We use GitVersion in our project, which throws the following error:
/root/.nuget/packages/gitversiontask/5.3.7/build/GitVersionTask.targets(46,9): error : InvalidOperationException: Could not find a 'develop' or 'master' branch, neither locally nor remotely.
According to this blog this happens, when the CI-server does not fetch the full repository (we have both a develop and a master branch, but I'm working on a different one). For Jenkins we solved this problem by expanding the checkout stage:
stage("Checkout") { gitlabCommitStatus(name: "Checkout") {
// These are the normal checkout instructions
cleanWs()
checkout scm
// This is the additional checkout to get all branches
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/'+env.BRANCH_NAME]],
extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
userRemoteConfigs: scm.userRemoteConfigs,
])
sh "git checkout ${env.BRANCH_NAME}"
sh "git reset --hard origin/${env.BRANCH_NAME}"
}}
I'm essentially looking for something equivalent to this for the .gitlab-ci.yml file.

