部署组将经典迁移到 yaml 管道的问题

问题描述 投票:0回答:1

我正在尝试将经典的 azure 发布管道迁移到 yaml,但我的一项工作失败了,我猜测这是由于部署组造成的。问题是这样的:

yaml 管道正在虚拟机上的 IIS 中部署应用程序,问题是当我移动部署组作业时,它失败了,因为它没有在预期的部署组上运行。

Yaml 管道如下所示:

parameters:
//params defined here

stages:
- stage: 
  dependsOn: 
  condition: 
  displayName:
  variables:            
    //variable groups defined here

  pool:
    name: 
  jobs:
  - deployment: Dep 1 
    displayName: 
    pool:
      name: 
    environment: 
      name: 
    strategy:
      runOnce:
        deploy:
          steps:
          
            - task: PowerShell@2
              displayName: ''
              inputs:
                targetType: 
                filePath: 
                arguments: 

  - deployment: Dep 2
    dependsOn: 
    displayName: 
    environment:
      name: 
      resourceType: VirtualMachine
    variables:
      #variables defined here
    
    strategy:
      runOnce:
        deploy:
          steps:
            - download: current
              artifact: drop
            
            - task: PowerShell@2
              displayName: ''
              inputs:
                targetType: 
                filePath: 
                arguments: 
              continueOnError: true

我正在努力寻找一种方法来强制我的版本在上面显示的 Dep 2 的特定部署组上运行。我尝试将部署组的名称合并到环境中,但它不起作用。

yaml cicd azure-pipelines-release-pipeline azure-devops-deploymentgroups
1个回答
0
投票

部署组仅适用于经典发布管道。如果您使用 YAML 管道,则需要使用环境。环境是您可以通过管道进行部署的目标资源的集合,它与经典管道中的部署组具有类似的功能。

- deployment: string 
用于定义部署作业的名称,而不是指定部署组。您可以将目标 VM 作为资源添加到环境中,然后部署到该环境。例如:

- stage: deploy
  jobs:
  - deployment: DeployApp
    displayName: deploy my App
    environment: 
      name: 'Dep 2'
      resourceName: myVM
      resourceType: virtualMachine
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo Hello world
© www.soinside.com 2019 - 2024. All rights reserved.