Skip to content

Commit bab8e6f

Browse files
Add ability to leave SourceBranch empty when queueing a build (builds using the default branch) (#831)
Co-authored-by: Daniel Jurek <[email protected]>
1 parent 3092401 commit bab8e6f

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

eng/common/scripts/Invoke-DevOpsAPI.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ function Start-DevOpsBuild {
1313
param (
1414
$Organization="azure-sdk",
1515
$Project="internal",
16-
[Parameter(Mandatory = $true)]
1716
$SourceBranch,
1817
[Parameter(Mandatory = $true)]
1918
$DefinitionId,

eng/common/scripts/Queue-Pipeline.ps1

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
<#
2+
.SYNOPSIS
3+
Queues an Azure DevOps Pipeline run optionally canceling similar runs
4+
5+
.PARAMETER Organization
6+
Azure DevOps organization name
7+
8+
.PARAMETER Project
9+
Azure DevOps project name
10+
11+
.PARAMETER SourceBranch
12+
Source branch use when executing the DevOps pipeline. Specifying an empty string
13+
will result in queuing of the run with the default branch configured for the
14+
pipeline.
15+
16+
.PARAMETER DefinitionId
17+
Pipline definition ID
18+
19+
.PARAMETER CancelPreviousBuilds
20+
Requires a value for SourceBranch. Cancel previous builds before queuing the new
21+
build.
22+
23+
.PARAMETER VsoQueuedPipelines
24+
Variable name to set in DevOps for the queued pipeline links
25+
26+
.PARAMETER Base64EncodedAuthToken
27+
Auth token for Azure DevOps API
28+
29+
.PARAMETER BuildParametersJson
30+
Additional build parameters to provide to the pipeline execution.
31+
32+
Of the format:
33+
34+
```json
35+
{
36+
"variable1": "value1",
37+
"variable2": "value2"
38+
}
39+
```
40+
41+
#>
42+
143
[CmdletBinding(SupportsShouldProcess = $true)]
244
param(
345
[Parameter(Mandatory = $true)]
@@ -6,7 +48,6 @@ param(
648
[Parameter(Mandatory = $true)]
749
[string]$Project,
850

9-
[Parameter(Mandatory = $true)]
1051
[string]$SourceBranch,
1152

1253
[Parameter(Mandatory = $true)]
@@ -26,7 +67,9 @@ param(
2667

2768
. (Join-Path $PSScriptRoot common.ps1)
2869

29-
if ($CancelPreviousBuilds)
70+
# Skip if SourceBranch is empty because it we cannot generate a target branch
71+
# name from an empty string.
72+
if ($CancelPreviousBuilds -and $SourceBranch)
3073
{
3174
try {
3275
$queuedBuilds = Get-DevOpsBuilds -BranchName "refs/heads/$SourceBranch" -Definitions $DefinitionId `

0 commit comments

Comments
 (0)