如何在Azure DevOps Server 2019内部部署中使用yaml模板参数? [英] How to use yaml template parameters in Azure DevOps Server 2019 on-prem?

查看:87
本文介绍了如何在Azure DevOps Server 2019内部部署中使用yaml模板参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据

那么我在做什么错了?(除了是忠实的TFS客户之外,他还受过时的本地Azure DevOps Server 2019困扰,与不断发展的托管Azure DevOps Services相比似乎无处可走)

解决方案

您没有做错任何事情.遗憾的是,这是我们的文件问题.

您尝试使用的语法是我们的​​新 rich YAML语法新功能,到目前为止,Azure DevOps Server 2019均不支持该功能.

为了在更改文档之前让公众知道并避免这种情况,我创建了一个线程并宣布此不支持

 参数:解决方案: '' 

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

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)

解决方案

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: ''

这篇关于如何在Azure DevOps Server 2019内部部署中使用yaml模板参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆