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="$env:BUILD_SOURCEBRANCHNAME"
$buildReason="$env:BUILD_REASON"
# Get PR information for branch
...
if ($branchHasPr -eq $True -and $buildReason -ne "PullRequest" -and $buildReason -ne "Manual") {
$doBuild = $False
Write-Host "Pr Build found, and not the merged PR build. Cancelled build."
}
...
if ($doBuild -eq $True) {
Write-Host "DoBuildVar=YES"
Write-Host "##vso[task.setvariable variable=DoBuildVar;isOutput=true]YES"
} else {
Write-Host "DoBuildVar=NO"
Write-Host "##vso[task.setvariable variable=DoBuildVar;isOutput=true]NO"
}
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.