Deployment Group issue on migrating classic to yaml pipeline

47 Views Asked by At

I am trying to migrate a classic azure release pipeline to yaml and one of my job is failing which my guess is due to deployment group. Here is the issue:

The yaml pipeline is deploying the app in IIS on a VM and the issue is when I moved the deployment group job it is failing as it is not running on the expected deployment group.

Yaml pipeline looks like below:

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

I am struggling to find a way to force my release to run on the specific deployment group for the Dep 2 shown above. I have tried to incorporate the name of deployment group in environment but it does not work.

1

There are 1 best solutions below

0
Ziyang Liu-MSFT On BEST ANSWER

Deployment groups are only available with classic release pipelines. If you are using YAML pipeline, you need to use the Environment. An environment is a collection of resources that you can target with deployments from a pipeline, which has similar functions to the deployment groups in the classic pipeline.

- deployment: string is used to define the name of the deployment job instead of specifying the deployment groups. You can add your target VM as a resource into an environment and then deploy to it. For example:

- 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