有没有办法在每个环境中使用 VSTS 变量组? [英] Is there a way to use VSTS Variable Groups per environment?
问题描述
我正在将我的配置从使用 web.config 转换转变为基于 VSTS 变量.我得到流程变量,你定义一个变量,选择一个环境,然后你就可以开始了.我还看到了变量组",这些看起来很棒,具有 KeyVault 集成,总体而言似乎是一个更好的选择.
但是...在我的 VSTS 发布过程中,我没有看到将变量组绑定到特定环境的方法.老实说,如果没有此功能,我无法理解这些对我有何用处.
我尝试了一种解决方法,但没有奏效.我试过了:
- 命名我的变量组 &带有环境前缀的变量,例如
- 变量组名称="生产连接字符串"
- 变量名="Production_LoggingConnectionString"
- 我以为一旦我链接了Production_ConnectionStrings"变量,我就可以从标准流程变量中引用 $(Production_LoggingConnectionString),但这不起作用.
我想我可以想出一些 powershell 来做类似上面的事情并设置变量,但这对我来说似乎有点太自定义了.
有没有其他人知道我可以轻松地为每个环境使用变量组,而无需等待 VSTS 构建此功能(如果有的话).顺便说一句,如果你想要这个功能,这里有一个建议你可以投票:
我没有找到有关此功能的任何版本信息,只是在调整版本时偶然发现了它.
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.
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:
- 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.
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.
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
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屋!