'Is there a way to bypass dependencies in an Azure multistage pipeline?

 - stage: DeployToIVT
    displayName: Deploy ${{join(' AND ', parameters.ivtEnv )}}
    dependsOn:
    - Build
    condition: |
        and
        (
          eq(dependencies.Build.result, 'Succeeded'),
          
            
            or
            (
              
              startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'),
              startsWith(variables['Build.SourceBranch'], 'refs/heads/refresh/')
            )   
        )

I have a master.yml that we use for multistage pipelines. The stage that deploys to QA is conditional based with a dependency on a successful build. Is there a way to uncheck build and just have the deploy stage checked in order to bypass that build dependency? When I try that it skips that stage all together and does nothing. I have tried adding a condition to say

  in(dependencies.Build.result, 'Succeeded', 'SucceededWithIssues', 'Skipped')

But the above does not work either.

Thanks



Solution 1:[1]

My team does something similar. We skip over the build stage and reuse artifacts from previous builds or bypass entire environments if we need to do a hotfix, etc.

We use a technique similar to following, where we add a variable at queue time that can shortcut conditions:

 - stage: Build
   displayName: 'CI'
   condition: ne(variables['deployWithoutBuild'], 'true')
   ...
 
 - stage: DeployToIVT
   displayName: Deploy ${{join(' AND ', parameters.ivtEnv )}}
   dependsOn:
    - Build
   condition: |
      or(
        and(
          in(dependencies.Build.result, 'Succeeded','SucceededWithIssues','Skipped',''),         
          or(
              startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'),
              startsWith(variables['Build.SourceBranch'], 'refs/heads/refresh/')
            )   
        ),
        eq(variables['deployWithoutBuild'], 'true')
      )

I believe checking for a '' build result was to accommodate if the stage was not included in the list of stages to run.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bryanbcook