Skip to content

Commit

Permalink
ApplyAdoBranchNameWorkaround.yml: Add file
Browse files Browse the repository at this point in the history
Moves workaround logic for branch names on ADO to a dedicated file
so it can be shared between other templates.

Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
makubacki committed Oct 17, 2022
1 parent ca7fbcf commit d6d4f56
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
18 changes: 18 additions & 0 deletions Steps/ApplyAdoBranchNameWorkaround.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## @file
# Azure Pipelines step template to apply a workaround for branch names
# on Azure DevOps (ADO).
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

steps:

# $System.PullRequest.targetBranch looks like "dev/whatever" on GitHub,
# but looks like "refs/heads/dev/whatever" on DevOps. The DevOps version
# can't be used for comparison for the PR Eval.
- powershell:
$TargetBranch = "$(System.PullRequest.targetBranch)".replace('refs/heads/', '');
Write-Host "##vso[task.setvariable variable=pr_compare_branch]origin/$TargetBranch";
displayName: Apply Branch Name Workaround
condition: condition: and(eq(variables['Build.Reason'], 'PullRequest'), contains(variables['System.PullRequest.TargetBranch'], 'refs/heads/'))
2 changes: 2 additions & 0 deletions Steps/BuildPlatform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ steps:
# Set default
- bash: echo "##vso[task.setvariable variable=pkg_count]${{ 1 }}"

- template: ApplyAdoBranchNameWorkaround.yml

# trim the package list if this is a PR
- task: CmdLine@1
displayName: Check if ${{ parameters.build_pkg }} Needs Testing
Expand Down
9 changes: 1 addition & 8 deletions Steps/PrGate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,7 @@ steps:
echo "##vso[task.setvariable variable=pkgs_to_build]${{ parameters.build_pkgs }}"
echo "##vso[task.setvariable variable=pkg_count]${{ 1 }}"
# $System.PullRequest.targetBranch looks like "dev/whatever" on GitHub,
# but looks like "refs/heads/dev/whatever" on DevOps. The DevOps version
# can't be used for comparison for the PR Eval.
- powershell:
$TargetBranch = "$(System.PullRequest.targetBranch)".replace('refs/heads/', '');
Write-Host "##vso[task.setvariable variable=pr_compare_branch]origin/$TargetBranch";
displayName: Apply Branch Name Workaround
condition: and(eq(variables['Build.Reason'], 'PullRequest'), contains(variables['System.PullRequest.TargetBranch'], 'refs/heads/'))
- template: ApplyAdoBranchNameWorkaround.yml

# Trim the package list if this is a PR
- ${{ if eq(parameters.do_pr_eval, true) }}:
Expand Down

0 comments on commit d6d4f56

Please sign in to comment.