Problem

I recently had a strange problem. I had an existing Azure DevOps YAML Pipeline that used the checkout task to do a deep Git fetch of a repo and it’s submodules. The reason for the deep fetch was that later in the pipeline we ran GitVersion and this needs the whole repo to be able to calculate the version.

- checkout: self
        persistCredentials: true
        submodules: true

- task: gitversion/setup@0
    displayName: 'Get current version of GitVersion'
    inputs:
    versionSpec: '5.x'

- task: gitversion/execute@0
    displayName: 'Run GitVersion to generate SEMVER'
    inputs:
    useConfigFile: true
    configFilePath: '$(System.DefaultWorkingDirectory)/GitVersion.yml'

On this original pipeline this was all working as expected.

However, when I created a second Azure DevOps pipeline that pointed to the same YAML file, expecting it to work without issues, it failed at the GitVersion task. It could not calculate the version.

On checking the pipeline logs, I could see that the git checkout had used a depth of 1 i.e. a shallow fetch, more efficient, but not providing all the branch and commit information GitVersion needs

The fix

It seems that on this 2nd pipeline the UX based pipeline settings were set differently, overriding the YAML ones, so causing a shallow fetch to be used.

ScreenShot

When I switched off the UX ‘set shallow fetch’ all worked as expected [accessed via Pipeline > Edit > Ellipsis menu > Triggers > YAML tab]

Confusing that a cloned pipeline should end up with different settings, especially when the setting you need to change is far from easily discoverable