How to skip Build without creating Drop and not triggering Release in Azure DevOps Currently we have a build pipeline which checks if there is a PR for the current branch and if yes it sets a variable and skips the other build steps.
But when this happens the Release still completes as Successful and a empty drop is created. This triggers a release which fails because drop is empty.
This is the dumbed down version of the build pipeline:
stages:
- stage: CheckShouldBuildStage
  displayName: Check Should Build
  jobs:
  - job: CheckShouldBuildJob
    displayName: Check Should Build
    steps:
      - powershell: |
            $doBuild = $True
            $sourceBranchName=&quot;$env:BUILD_SOURCEBRANCHNAME&quot;
            $buildReason=&quot;$env:BUILD_REASON&quot;
            
            # Get PR information for branch
            ...
            
            if ($branchHasPr -eq $True -and $buildReason -ne &quot;PullRequest&quot; -and $buildReason -ne &quot;Manual&quot;) {
               $doBuild = $False
               Write-Host &quot;Pr Build found, and not the merged PR build. Cancelled build.&quot;
            }

            ...

           if ($doBuild -eq $True) {
              Write-Host &quot;DoBuildVar=YES&quot;
              Write-Host &quot;##vso[task.setvariable variable=DoBuildVar;isOutput=true]YES&quot;     
            } else { 
              Write-Host &quot;DoBuildVar=NO&quot;
              Write-Host &quot;##vso[task.setvariable variable=DoBuildVar;isOutput=true]NO&quot;
            }
        name: CheckShouldBuildTask
        displayName: Check Should Build
- stage: BuildAndTest
  condition: 
    eq(
      dependencies.CheckShouldBuildStage.outputs['CheckShouldBuildJob.CheckShouldBuildTask.DoBuildVar'], 
      'YES'
    )
  dependsOn: CheckShouldBuildStage
  displayName: Build and Test
  jobs:
     ...

What should be the correct way to skip a build and not trigger a Release? Is it possible to just disable the creation of an empty drop?
I tried to disable the creation of an empty drop, but all my search results are just people where there was no drop created on mistake.. so this was a dead-end.
I also know I can just fail my build pipeline but this would show up in the stats. As far as I can tell there really only is Success and Fail as a status for a pipeline. So this solution is also not working out for me.
Try and add a Stage condition to only run that stage for a specific branch.
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))


stages:
- stage: A
             .....

- stage: B
  **condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))**
  jobs:
  - job: B1
    steps:
      - script: echo Hello Stage B!
      - script: echo $(isMain)

Reference : https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&amp;tabs=yaml
PS : Will refine the answer in future, currently we are still using GUI for releases and we are using this branch filter to control this scenario.