Skip to content

Commit f2d23ef

Browse files
lbussellmthalman
andauthored
Fix branch validation (#1263)
Co-authored-by: Matt Thalman <[email protected]>
1 parent 99579de commit f2d23ef

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

eng/common/templates/steps/validate-branch.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,25 @@ parameters:
44
steps:
55
- ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest')) }}:
66
- powershell: |
7-
if (-not "$(officialBranches)".Split(',').Contains("$(sourceBranch)") `
8-
-and "$(officialBranches)".Split(',').Contains("$(publishRepoPrefix)") `
9-
-and "$(overrideOfficialBranchValidation)" -ne "true")
7+
if ("$(officialBranches)".Split(',').Contains("$(sourceBranch)") `
8+
-and "$(officialRepoPrefixes)".Split(',').Contains("$(publishRepoPrefix)"))
109
{
11-
echo "##vso[task.logissue type=error]Official builds must be done from an official branch: $(officialBranches)"
12-
exit 1
10+
echo "Conditions met for official build, continuing..."
11+
exit 0
1312
}
13+
14+
if (-not "$(officialRepoPrefixes)".Split(',').Contains("$(publishRepoPrefix)"))
15+
{
16+
echo "This build is a test build, continuing..."
17+
exit 0
18+
}
19+
20+
if ("$(overrideOfficialBranchValidation)" -eq "true")
21+
{
22+
echo "Variable overrideOfficialBranchValidation is set to true, continuing..."
23+
exit 0
24+
}
25+
26+
echo "##vso[task.logissue type=error]Official builds must be done from an official branch ($(officialBranches)) and repo prefix ($(officialRepoPrefixes))."
27+
exit 1
1428
displayName: Validate Branch

eng/common/templates/variables/common.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ variables:
3232
- name: officialBranches
3333
# comma-delimited list of branch names
3434
value: main
35+
- name: overrideOfficialBranchValidation
36+
value: false
3537
- name: mirrorRepoPrefix
3638
value: 'mirror/'
3739
- name: cgBuildGrepArgs

0 commit comments

Comments
 (0)