Skip to content

Commit

Permalink
Fix branch validation (#1263)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Thalman <[email protected]>
  • Loading branch information
lbussell and mthalman authored Apr 30, 2024
1 parent 99579de commit f2d23ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 19 additions & 5 deletions eng/common/templates/steps/validate-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@ parameters:
steps:
- ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest')) }}:
- powershell: |
if (-not "$(officialBranches)".Split(',').Contains("$(sourceBranch)") `
-and "$(officialBranches)".Split(',').Contains("$(publishRepoPrefix)") `
-and "$(overrideOfficialBranchValidation)" -ne "true")
if ("$(officialBranches)".Split(',').Contains("$(sourceBranch)") `
-and "$(officialRepoPrefixes)".Split(',').Contains("$(publishRepoPrefix)"))
{
echo "##vso[task.logissue type=error]Official builds must be done from an official branch: $(officialBranches)"
exit 1
echo "Conditions met for official build, continuing..."
exit 0
}
if (-not "$(officialRepoPrefixes)".Split(',').Contains("$(publishRepoPrefix)"))
{
echo "This build is a test build, continuing..."
exit 0
}
if ("$(overrideOfficialBranchValidation)" -eq "true")
{
echo "Variable overrideOfficialBranchValidation is set to true, continuing..."
exit 0
}
echo "##vso[task.logissue type=error]Official builds must be done from an official branch ($(officialBranches)) and repo prefix ($(officialRepoPrefixes))."
exit 1
displayName: Validate Branch
2 changes: 2 additions & 0 deletions eng/common/templates/variables/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ variables:
- name: officialBranches
# comma-delimited list of branch names
value: main
- name: overrideOfficialBranchValidation
value: false
- name: mirrorRepoPrefix
value: 'mirror/'
- name: cgBuildGrepArgs
Expand Down

0 comments on commit f2d23ef

Please sign in to comment.