如何从YAML构建管道访问VSTS变量组?

时间:2018-08-21 08:07:48

标签: azure-devops azure-pipelines

我目前正在将VSTS构建管道转换为YAML build definions。但是,我还找不到在YAML文件中使用Variable Group变量的方法。如果像以前一样在构建管道中引用了变量,那么PowerShell脚本似乎无法找到它。

- powershell: |
    Write-Output Testing...
    Write-Output "DatabaseName: $(AzureSqlDb_DatabaseName)"
  displayName: Output Library Vars

详细的错误消息如下:

AzureSqlDb_DatabaseName : The term 'AzureSqlDb_DatabaseName' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\a\_temp\e06f9ee7-8418-4339-a976-ed78a0e71021.ps1:3 char:31
+ Write-Output "DatabaseName: $(AzureSqlDb_DatabaseName)"
+                               ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (AzureSqlDb_DatabaseName:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : CommandNotFoundException

##[debug]Exit code: 1
##[debug]Leaving Invoke-VstsTool.
##[error]PowerShell exited with code '1'.

如您所见,我已经为构建管道启用了system.debug。所以:

  • 使用变量组是否已受支持?
  • 如果是,引用这些变量的方式是什么?

1 个答案:

答案 0 :(得分:2)

解决方案非常简单。就像常规构建管道一样,您还需要从VSTS门户将变量组链接到YAML构建管道。此处描述了此方法:Use a variable group

相关问题