如何从YAML构建管道访问VSTS变量组? [英] How to access VSTS Variable Groups from YAML build pipeline?

查看:76
本文介绍了如何从YAML构建管道访问VSTS变量组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将VSTS构建管道转换为变量组.如果像以前一样在构建管道中引用变量,那么PowerShell脚本似乎无法找到它.

I'm currently in the process of converting VSTS build pipelines to YAML build definions. However I can't yet find a way to use variables of a Variable Group within my YAML file. If I reference a variable, just like before within a build pipeline, the PowerShell script doesn't seem to be able to find it.

- 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.所以:

As you can see, I've already enabled system.debug for the build pipeline. So:

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

推荐答案

解决方案非常简单.就像普通构建管道一样,您还需要从VSTS门户将变量组链接到YAML构建管道.此处描述了此方法:使用变量组.

The solution was very simple. Just like with a normal build pipeline, you also need to link a variable group to the YAML build pipeline from the VSTS portal. The way to this is described here: Use a variable group.

这篇关于如何从YAML构建管道访问VSTS变量组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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