组名称变量在Azure管道中可以动态吗? [英] Can group name variable be dynamic in azure pipelines?

查看:109
本文介绍了组名称变量在Azure管道中可以动态吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个天蓝色的环境.它们之间的区别仅在于来自变量组的环境变量.是否可以为一个管道动态设置组名,而不是设置两个可以映射自己的组变量的管道? 这是我的构建管道的一个例子

I have two environments on azure. One difference between them is only environment variables that came from variable groups. Is it possible to set up group name dynamically for one pipeline instead of set up two pipelines that can map their own group variables? It is an example of my build pipeline

trigger:
  - master
  - develop


jobs:

- job: DefineVariableGroups
   steps:
    - script: |
      if [ $(Build.SourceBranch) = 'refs/heads/master' ]; then
        echo "##vso[task.setvariable variable=group_name_variable;isOutput=true]beta_group"
      elif [ $(Build.SourceBranch) = 'refs/heads/develop' ]; then
        echo "##vso[task.setvariable variable=group_name_variable;isOutput=true]alpha_group"
      fi
    name: 'DefineVariableGroupsTask'
  - script: echo $(DefineVariableGroupsTask.group_name_variable)
    name: echovar # that works.

- job: Test
  dependsOn: DefineVariableGroups
  pool:
    vmImage: 'Ubuntu-16.04'
  variables:
    - group: $[ dependencies.DefineVariableGroups.outputs['DefineVariableGroupsTask.group_name_variable'] ]
    # that doesn't work. Error here
steps:
  - script: echo $(mode)
    displayName: 'test'

推荐答案

组名变量在天青管道中可以动态吗?

Can group name variable be dynamic in azure pipelines?

很抱歉给您带来不便.

目前恐怕不支持此操作.因此,我们必须在YAML管道中声明要使用的变量组.

I am afraid this is not supported at this moment. So we have to declare the variable group you want to consume in a YAML pipeline.

其他一些社区较早提出了相同的要求,并且此要求已传递给产品团队,您可以从故障单中查看详细信息:

Some other communities raised the same requirement earlier, and this requirement has been passed to product team, you can check the details from the ticket:

门票:动态变量组?

注意:您可以对此反馈进行投票并添加评论.当有足够的社区对此反馈进行投票并添加评论时,产品团队成员将认真对待此反馈.

Note: You can vote and add your comments for this feedback. When there are enough communities vote and add comments for this feedback, the product team member will take this feedback seriously.

希望这会有所帮助.

这篇关于组名称变量在Azure管道中可以动态吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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