Skip to content

Commit

Permalink
Add ability to use Queue-Pipeline.ps1 with an empty SourceBranch and …
Browse files Browse the repository at this point in the history
…document
  • Loading branch information
danieljurek committed Jul 27, 2021
1 parent 16b487e commit f31688a
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion eng/common/scripts/Queue-Pipeline.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
<#
.SYNOPSIS
Queues an Azure DevOps Pipeline run optionally canceling similar runs
.PARAMETER Organization
Azure DevOps organization name
.PARAMETER Project
Azure DevOps project name
.PARAMETER SourceBranch
Source branch use when executing the DevOps pipeline. Specifying an empty string
will result in queuing of the run with the default branch configured for the
pipeline.
.PARAMETER DefinitionId
Pipline definition ID
.PARAMETER CancelPreviousBuilds
Requires a value for SourceBranch. Cancel previous builds before queuing the new
build.
.PARAMETER VsoQueuedPipelines
Variable name to set in DevOps for the queued pipeline links
.PARAMETER Base64EncodedAuthToken
Auth token for Azure DevOps API
.PARAMETER BuildParametersJson
Additional build parameters to provide to the pipeline execution.
Of the format:
```json
{
"variable1": "value1",
"variable2": "value2"
}
```
#>

[CmdletBinding(SupportsShouldProcess = $true)]
param(
[Parameter(Mandatory = $true)]
Expand Down Expand Up @@ -25,7 +67,9 @@ param(

. (Join-Path $PSScriptRoot common.ps1)

if ($CancelPreviousBuilds)
# Skip if SourceBranch is empty because it we cannot generate a target branch
# name from an empty string.
if ($CancelPreviousBuilds -and $SourceBranch)
{
try {
$queuedBuilds = Get-DevOpsBuilds -BranchName "refs/heads/$SourceBranch" -Definitions $DefinitionId `
Expand Down

0 comments on commit f31688a

Please sign in to comment.