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

Azure devops 如何从YAML构建管道访问VSTS变量组?,azure-devops,azure-pipelines,Azure Devops,Azure Pipelines,我目前正在将VST构建管道转换为。然而,我还没有找到在YAML文件中使用a变量的方法。如果像以前一样在构建管道中引用变量,PowerShell脚本似乎无法找到它 - powershell: | Write-Output Testing... Write-Output "DatabaseName: $(AzureSqlDb_DatabaseName)" displayName: Output Library Vars 详细的错误消息如下: AzureSqlDb_Databas

我目前正在将VST构建管道转换为。然而,我还没有找到在YAML文件中使用a变量的方法。如果像以前一样在构建管道中引用变量,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。因此:

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

    • 解决方案非常简单。与普通构建管道一样,还需要从VSTS门户将变量组链接到YAML构建管道。这里描述了实现此目的的方法:.

      使用$env:AzureSqlDb_DatabaseName时,它也不起作用,而不是使用$(AzureSqlDb_DatabaseName)。尽管如此,在这种情况下不会出现错误。另请参见:对于那些陷入此问题的人,Azure DevOps中的“变量”选项卡隐藏在“管道>构建”屏幕的“编辑”链接后面。