2
votes

According to the official documentation at https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops-2019 the Azure DevOps Server 2019 on-prem supports everything.

Yet, I cannot make it work with a simple yaml template with parameters.

Here is my yaml template (named prepare-sonar-qube.yml):

parameters:
- name: projectKey
  type: string

- name: projectName
  type: string
  default: ${{ parameters.projectKey }}

- name: useDotCover
  type: boolean
  default: false

steps:
- template: install-java.yml

- task: SonarQubePrepare@4
  displayName: 'Prepare SQ Analysis'
  inputs:
    SonarQube: 'SonarQube'
    scannerMode: 'MSBuild'
    projectKey: parameters.projectKey
    projectName: parameters.projectName
    ${{ if parameters.useDotCover }}: 
      extraProperties: |
        sonar.cs.dotcover.reportsPaths=$(Common.TestResultsDirectory)\coverage\*.CoverageResult.html
        sonar.inclusions=**/*.cs
    ${{ if !parameters.useDotCover }}: 
      extraProperties: |
        sonar.cs.opencover.reportsPaths=$(Common.TestResultsDirectory)\coverage\*.CoverageResult.xml 
        sonar.inclusions=**/*.cs

Here is the azure-pipelines.yml:

trigger:
- master

name: 1.0.$(Date:yy)$(DayOfYear)$(Rev:.r)

jobs:
- job: Build
  pool:
    demands: DotNetFramework
  workspace:
    clean: all
  variables:
  - template: variables.yml  
  steps:
  - template: prepare-sonar-qube.yml
    parameters:
      projectKey: logs2db

...

Running the build I get the following lovely error message:

/prepare-sonar-qube.yml (Line: 2, Col: 1): A sequence was not expected

enter image description here

So what am I doing wrong? (Besides being a loyal TFS customer who got stuck with an outdated on-prem Azure DevOps Server 2019 that does not seem to go anywhere when compared against the ever evolving hosted Azure DevOps Services)

2

2 Answers

-1
votes

You do not did anything wrong. Need sorry to say, that is our document issue.

The syntax you are trying is our new richer YAML syntax feature, which haven't supported in Azure DevOps Server 2019 until now.

To let public know and avoid this before we make changes to document, I create a thread and announce this unsupport here.


At present, the on-prem server only support the older syntax, where defaults are declared as a mapping without type or value constraints:

parameters:
  solution: '**/*.sln'

Or

parameters:
  solution: ''
0
votes

This looks like a simple indentation issue.

Here's a snip from one of my working templates.

parameters:
  - name: sln
    type: string
    default: ''
  - name: slnName
    type: string
    default: ''
  - name: proj
    type: string
    default: ''

Try using space space - name: [name]