Search code examples
azure-devopsyaml

Azure Dev Ops yaml pipeline run one target at a time


I want to run a pipeline that looks like this:

stages:
- ${{each environment in parameters.environments}}:
    - stage:
      displayName:  ${{ Replace(environment, '-', '_') }}
      dependsOn: ''
      jobs:
        - deployment: Run_script_${{ Replace(environment, '-', '_') }}
          environment: 
            name: '${{ environment }}'
            resourceType: 'VirtualMachine'
          condition: succeeded()
          strategy:
              runOnce:    
                deploy:    
                    steps:
                    - checkout:  none`

Where I can target one environment (in this case environment is an object parameter that can contain many environments and will run a stage for each environment) but each resource is targeted one at a time to run the work rather than in parallel. Is there a way to do this i'm missing?

I was hoping I could use condition: succeeded() in order to specify "if its the first job or if the previous job succeeded" but it seems that doesn't work. I'm not sure what else to try.

Thanks


Solution

  • Turns out I was over complicating it, I can just use the "Rolling" deployment type and set maxParallel to 1.

              strategy:
                  rolling:
                    maxParallel: 1