可以在Azure YAML管道的部署作业类型中设置多个环境值吗?

huangapple go评论138阅读模式
英文:

Can an Azure YAML Pipelines deployment job type, have mutiple environment values?

问题

在部署作业的环境属性中是否有可能拥有多个值?类似于这个示例:

stages:
    - stage:
        jobs:
            - deployment:
                environment:
                    - environmentOne
                    - environmentTwo
                strategy:
                    runOnce:
                        deploy:
                            steps:
                                - script: echo hello

微文档没有提到这一点。我还发现了这篇博客文章,但对于我的情况,环境的唯一目的是用于执行环境的批准和检查

英文:

Is there any possibility to have mutiple values in the environment property of deployment jobs? Something similar to this example:

stages:
    - stage: 
      jobs:
          - deployment: 
            environment:  
              - environmentOne
              - environmentTwo
            strategy:
              runOnce:
                deploy:
                  steps:
                    - script: echo hello

Micro doc do not make any allusion about that. I also found this blog, but for my case, the only porpuse of the environments is for the execution of the environment approvals and checks

答案1

得分: 1

最简化的解决方案只需使用each关键字和对象参数来指定环境。

parameters:
- name: environments
  type: object
  default: 
  - environmentOne
  - environmentTwo

stages:
    - stage: 
      jobs:
      - ${{ each environment in parameters.environments }}:
        - deployment: 
          environment: ${{ environment }}
          strategy:
            runOnce:
              deploy:
                steps:
                  - script: echo hello
英文:

The most simplified solution would be just to use the each keyword and object parameter to specify the environments.

parameters:
- name: environments
  type: object
  default: 
  - environmentOne
  - environmentTwo

stages:
    - stage: 
      jobs:
      - ${{ each environment in parameters.environments }}:
        - deployment: 
          environment: ${{ environment }}
          strategy:
            runOnce:
              deploy:
                steps:
                  - script: echo hello

huangapple
  • 本文由 发表于 2023年8月10日 18:33:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76874908.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定