C#C
C#2y ago
TeBeCo

[Azure Devops] Deploy Pipeline

I have a Multi stage pipeline conditionned like this:
(this is done as a full YAML file)
* trigger: all branch
* Build (no condition)
* Deploy to EnvA (condition: branch: `main`)
* Deploy to EnvB (condition: branch: `main`)
* Deploy to EnvC (condition: branch: `main`)

the idea is to have a normal CI/CD

Thing is ... time to time we want to deploy to env B directly for "experimentation, this would use the artifact that could have been built from the Build stage maybe the day earlier, we just don't know when
anybody know how to do that with YAML in azure devops ?

I'm fine creating a dedicated yaml pipeline just for that, but I'm not sure how to do the "pick a build artifact" with YAML
this is what the baseline look like for the YAML:
https://paste.mod.gg/moxtmhagsabb/0

trigger:
  branches:
    include:
      - "*"

pool:
  vmImage: ubuntu-latest

stages:
  - stage: "Build"
    jobs:
          - script: dotnet publish ./src/Foo/Foo.csproj -o ./publish
            displayName: "dotnet publish"

          - task: ArchiveFiles@2
            inputs:
              includeRootFolder: false
              rootFolderOrFile: "./publish"
              archiveFile: "$(Build.ArtifactStagingDirectory)/Foo.zip"

          - publish: "$(Build.ArtifactStagingDirectory)"
            artifact: "Drop"
  - stage: "Stage_A"
    condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/main'))
    jobs:
      - deployment: "Deploy_A"
        displayName: "Deploy to A"
        environment: "A"
        variables:
          X: 1
        strategy:
          runOnce:
            deploy:
              steps:
                - script: echo 'bla $(X)'
  - stage: "Stage_B"
    condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/main'))
    jobs:
      - deployment: "Deploy_B"
        displayName: "Deploy to B"
        environment: "B"
        variables:
          X: 2
        strategy:
          runOnce:
            deploy:
              steps:
                - script: echo 'bla $(X)'
  - stage: "Stage_C"
    condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/main'))
    jobs:
      - deployment: "Deploy_C"
        displayName: "Deploy to C"
        environment: "C"
        variables:
          X: 3
        strategy:
          runOnce:
            deploy:
              steps:
                - script: echo 'bla $(X)'
image.png
image.png
Was this page helpful?