root: fix branch Name extraction to work on non PRs
This commit is contained in:
parent
1149a8d9a4
commit
21d6a28715
|
@ -375,9 +375,7 @@ stages:
|
|||
inputs:
|
||||
targetType: 'inline'
|
||||
script: |
|
||||
set -x
|
||||
branchName=$(echo "$(System.PullRequest.SourceBranch)" | sed "s/\//-/g")
|
||||
echo "##vso[task.setvariable variable=branchName]$branchName"
|
||||
python ./scripts/az_do_set_branch.py
|
||||
- task: Docker@2
|
||||
inputs:
|
||||
containerRegistry: 'dockerhub'
|
||||
|
|
|
@ -95,9 +95,7 @@ stages:
|
|||
inputs:
|
||||
targetType: 'inline'
|
||||
script: |
|
||||
set -x
|
||||
branchName=$(echo "$(System.PullRequest.SourceBranch)" | sed "s/\//-/g")
|
||||
echo "##vso[task.setvariable variable=branchName]$branchName"
|
||||
python ./scripts/az_do_set_branch.py
|
||||
- task: Docker@2
|
||||
inputs:
|
||||
containerRegistry: 'dockerhub'
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
"""Helper script to get the actual branch name, docker safe"""
|
||||
import os
|
||||
|
||||
env_pr_branch = "SYSTEM_PULLREQUEST_SOURCEBRANCH"
|
||||
default_branch = "BUILD_SOURCEBRANCHNAME"
|
||||
|
||||
branch_name = os.environ[default_branch]
|
||||
if env_pr_branch in os.environ:
|
||||
branch_name = os.environ[env_pr_branch].replace("/", "-")
|
||||
|
||||
print("##vso[task.setvariable variable=branchName]%s" % branch_name)
|
|
@ -75,9 +75,7 @@ stages:
|
|||
inputs:
|
||||
targetType: 'inline'
|
||||
script: |
|
||||
set -x
|
||||
branchName=$(echo "$(System.PullRequest.SourceBranch)" | sed "s/\//-/g")
|
||||
echo "##vso[task.setvariable variable=branchName]$branchName"
|
||||
python ./scripts/az_do_set_branch.py
|
||||
- task: Docker@2
|
||||
inputs:
|
||||
containerRegistry: 'dockerhub'
|
||||
|
|
Reference in New Issue