We have been migrating our existing pipelines for our projects to use GitVersion and yml files instead of Azure DevOps UI steps. We did the initial run and testing 2 months ago and it's been working fine for some projects already.
Today, I'm trying to migrate another one to use GitVersion and getting errors like following for same set up and GitVersion.yml.
When I try to build the feature branches, I got the following error at gitversion/execute@0 step:
System.InvalidOperationException: Gitversion could not determine which branch to treat as the development branch (default is 'develop') nor release-able branch (default is 'main' or 'master'), either locally or remotely. Ensure the local clone and checkout match the requirements or considering using 'GitVersion Dynamic Repositories'
It works for builds on develop and master branches
GitVersion.yml
next-version: 15.0.0
assembly-informational-format: '{SemVer}'
ignore:
commits-before: '2021-01-01T00:00:00'
branches:
develop:
tag: beta
feature:
mode: ContinuousDeployment
tag: alpha
release:
tag: rc
increment: Minor
track-merge-target: true
main:
track-merge-target: true
hotfix:
tag: rc
Pipeline Yml
trigger:
branches:
include:
- develop
- releases/*
- release/*
- hotfixes/*
- hotfix/*
- master
paths:
include:
- src/*
pool:
vmImage: ubuntu-latest
variables:
buildConfiguration: 'release'
steps:
- checkout: self
fetchDepth: 100000
clean: true
persistCredentials: true
- task: gitversion/setup@0
displayName: gitversion/setup
inputs:
versionSpec: 5.x
- task: gitversion/execute@0
displayName: gitversion/execute
inputs:
useConfigFile: true
configFilePath: GitVersion.yml
- script: echo "##vso[build.updatebuildnumber]$(GitVersion.SemVer)"
Other build steps are removed for clarity.
I tried to add regex: ^features?[/-]
(which is the default regex) under feature: in GetVersion.yml. But error still the same.
I did have both develop and master branches in my repo.
Could you please suggest me how I could resolve this issue?
Our DevOps expert managed to solve the issue by changing the following lines.
He mentioned that it might be related to recent Microsoft release as per @Matt comment.
steps:
- checkout: self
fetchDepth: 1 <<< updated this line
clean: true
persistCredentials: true
- task: gitversion/setup@0
displayName: gitversion/setup
inputs:
versionSpec: 5.x
- script: git fetch --unshallow --all <<< added this line