有没有一种方法可以在每个环境中使用VSTS变量组? [英] Is there a way to use VSTS Variable Groups per environment?
问题描述
我将配置从使用web.config转换转移到基于VSTS变量.我得到了过程变量,您定义了一个变量,选择了一个环境,然后您就可以开始了.我还看到了变量组",它们看起来很棒,具有KeyVault集成,并且总体看来是一个更好的选择.
I'm moving my configuration from using web.config transforms to being based on VSTS variables. I get process variables, you define a variable, pick an environment, and you're good to go. I also see "Variable Groups", these seem great, have KeyVault integration, and overall seem like a much better option.
但是...我在VSTS发行过程中没有看到将变量组绑定到特定环境的方法.老实说,如果没有此功能,我将无法理解这些功能.
But...I don't see a way to bind a Variable Group to a specific environment in my VSTS release process. I can't honestly see how these would be any use to me without this feature.
我已经尝试了一种解决方法,但是没有成功.我试过了:
I've experimented with one workaround, but it didn't work. I tried:
- 命名我的变量组&具有环境前缀的变量,例如
- 变量组名=生产连接字符串"
- 变量名称="Production_LoggingConnectionString"
- 我以为一旦链接了"Production_ConnectionStrings"变量,我就可以在标准Process变量中引用$(Production_LoggingConnectionString),但这是行不通的.
- Naming my variable group & variables with an environment prefix e.g.
- Variable Group Name="Production ConnectionStrings"
- Variable name="Production_LoggingConnectionString"
- I thought once I linked the "Production_ConnectionStrings" variable, I could reference $(Production_LoggingConnectionString) from within a standard Process variable, but this didn't work.
我想我可以想到一些可以执行上述操作并设置变量的powershell,但这对我来说似乎太自定义了.
I think I could come up with some powershell that would do something like the above and set variables, but this seems a bit too custom for me.
其他人是否有想法,我可以轻松地在每个环境中使用变量组,而无需等待VSTS来构建此功能(如果有的话).顺便说一句,如果您需要此功能,可以在这里提出建议:
Does anyone else have an idea that I can use variable groups per environment, easily, without waiting around for VSTS to build this feature (if ever). Btw, if you want this feature, there is a suggestion here you can upvote: Make it possible to link a variable group to a specific environment in a release definition
推荐答案
这已在VSTS变量组中作为范围实现.转到发布定义->变量->变量组->链接变量组,您将看到如下所示的链接窗口,您可以在其中选择要发布的范围或一个或多个环境的范围!
This has now been implemented in VSTS variable groups as scopes. Go to your release definition -> Variables -> Variable Groups -> Link variable group, and you get the link window as below, where you can choose the scope to be either release or one or more of your environments!
我没有找到有关此功能的任何发行信息,只是在调整发行版时偶然发现了它.
I did not manage to find any release information on this feature, I just stumbled upon it as I was tweaking my releases.
这篇关于有没有一种方法可以在每个环境中使用VSTS变量组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!