Azure Pipelines: error occurred while loading the YAML build pipeline: wrong number of segments

Viewed 8150

I copied an azure-pipelines.yml from one project to another, and it won't build. I've made sure that everything is the same, and the same extensions are installed on both sides...

The old build still works, but the new one does not:

An error occurred while loading the YAML build pipeline. wrong number of segments

Here's the YAML:

# https://aka.ms/yaml
name: $(Build.DefinitionName)_$(GitVersion_InformationalVersion)
pr:
- master
pool:
  vmImage: 'VS2017-Win2016'    

steps:
- task: gittools.gitversion.gitversion-task.GitVersion@3
  displayName: GitVersion

- powershell: .\bootstrap.ps1
  displayName: 'Restore pre-requisites'

- powershell: .\build.ps1 -OutputDirectory $(Build.ArtifactStagingDirectory)\$(Build.DefinitionName) -SemVer $(GitVersion.InformationalVersion) -Verbose
  displayName: 'Run build script'

- task: richardfennellBM.BM-VSTS-PesterRunner-Task.Pester-Task.Pester@8
  displayName: 'Pester Tests'
  inputs:
    additionalModulePath: '$(Build.ArtifactStagingDirectory)'
    CodeCoverageFolder: '$(Build.ArtifactStagingDirectory)'
    resultsFile: '$(Common.TestResultsDirectory)\Test-$(Build.DefinitionName)_$(Build.BuildNumber).xml'
    CodeCoverageOutputFile: '$(Common.TestResultsDirectory)\Coverage-$(Build.DefinitionName)_$(Build.BuildNumber).xml'

- task: PublishTestResults@2
  displayName: 'Publish Test Results'
  condition: always()
  inputs:
    testRunner: NUnit
    searchFolder: '$(Common.TestResultsDirectory)'

- task: PublishCodeCoverageResults@1
  displayName: 'Publish code coverage'
  inputs:
    summaryFileLocation: '$(Common.TestResultsDirectory)\Coverage-$(Build.DefinitionName)_$(Build.BuildNumber).xml'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: Module'
  inputs:
    ArtifactName: Module
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
1 Answers

It turns out this error message indicates the VERSION of the extension was wrong. I have to nominate the message for least helpful ever...

The GitVersion task has (finally!) released version 4 and in the Azure Pipeline world, that apparently means that v3 is deprecated. Thus, new teams who install that task extension now only have v4 available (although the team where I copied the yaml from still has v3).

The solution was to change the first step to:

steps:
- task: gittools.gitversion.gitversion-task.GitVersion@4
  displayName: GitVersion
Related