From d8222302f9b5d0585fee37b89e7272f1fcdc5611 Mon Sep 17 00:00:00 2001 From: Denis Rumyantsev Date: Wed, 7 Feb 2024 09:56:58 +0100 Subject: [PATCH] fix switch to target branch ci step (#4636) --- .azure-pipelines/build-job.yml | 7 +++---- .azure-pipelines/scripts/Switch-Branch.ps1 | 8 -------- .azure-pipelines/scripts/switch-branch.sh | 11 +++++++++++ .vsts.release.yml | 7 +++---- 4 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 .azure-pipelines/scripts/Switch-Branch.ps1 create mode 100644 .azure-pipelines/scripts/switch-branch.sh diff --git a/.azure-pipelines/build-job.yml b/.azure-pipelines/build-job.yml index 087c519fb8..da496ccf23 100644 --- a/.azure-pipelines/build-job.yml +++ b/.azure-pipelines/build-job.yml @@ -99,11 +99,10 @@ jobs: - checkout: self clean: true - - task: PowerShell@2 - displayName: 'Switch to target branch' + - task: Bash@3 + displayName: Switch to target branch inputs: - targetType: 'filePath' - filePath: .azure-pipelines/scripts/Switch-Branch.ps1 + filePath: .azure-pipelines/scripts/switch-branch.sh env: TARGET_BRANCH: $(CheckoutBranch) condition: | diff --git a/.azure-pipelines/scripts/Switch-Branch.ps1 b/.azure-pipelines/scripts/Switch-Branch.ps1 deleted file mode 100644 index a3bfda75d6..0000000000 --- a/.azure-pipelines/scripts/Switch-Branch.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -git config user.email "azure-pipelines-bot@microsoft.com" -git config user.name "azure-pipelines-bot" - -git checkout -f origin/$env:TARGET_BRANCH - -if ($LASTEXITCODE -ne 0){ - Write-Error "git checkout failed with exit code $LASTEXITCODE" -ErrorAction Stop -} diff --git a/.azure-pipelines/scripts/switch-branch.sh b/.azure-pipelines/scripts/switch-branch.sh new file mode 100644 index 0000000000..ff1bfff911 --- /dev/null +++ b/.azure-pipelines/scripts/switch-branch.sh @@ -0,0 +1,11 @@ +git config user.email "azure-pipelines-bot@microsoft.com" +git config user.name "azure-pipelines-bot" + +git checkout -f origin/$TARGET_BRANCH + +last_exit_code=$? + +if [[ $last_exit_code != 0 ]]; then + echo "git checkout failed with exit code $last_exit_code" + exit 1 +fi diff --git a/.vsts.release.yml b/.vsts.release.yml index 0b938c1203..e6368c6960 100644 --- a/.vsts.release.yml +++ b/.vsts.release.yml @@ -172,11 +172,10 @@ extends: - checkout: self clean: true - - task: PowerShell@2 - displayName: 'Switch to release branch' + - task: Bash@3 + displayName: Switch to release branch inputs: - targetType: 'filePath' - filePath: .azure-pipelines/scripts/Switch-Branch.ps1 + filePath: .azure-pipelines/scripts/switch-branch.sh env: TARGET_BRANCH: $(ReleaseBranch)