Skip to content

Commit d84222d

Browse files
Added a new Extract_PR_Number job to parse the PR number from System.PullRequest.SourceBranch
1 parent 8313138 commit d84222d

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

.pipelines/ci.yml

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ variables:
3939
stages:
4040
- stage: Containerized_CI
4141
variables:
42-
- name: PR_NUMBER
43-
value: ""
4442
- name: TAG
4543
value: ""
4644
jobs:
@@ -50,33 +48,39 @@ stages:
5048
steps:
5149
# Debugging: Output the SourceBranch value
5250
- bash: |
51+
echo "DEBUG: Inspecting System.PullRequest.SourceBranch..."
5352
echo "System.PullRequest.SourceBranch is: $(System.PullRequest.SourceBranch)"
5453
echo "System.PullRequest.SourceCommitId is: $(System.PullRequest.SourceCommitId)"
55-
echo "##vso[task.logissue type=warning] Debug output: Source Branch: $(System.PullRequest.SourceBranch), Commit SHA: $(System.PullRequest.SourceCommitId)"
54+
echo "##vso[task.logissue type=warning] Source Branch: $(System.PullRequest.SourceBranch)"
5655
displayName: Debug Source Branch Information
5756
58-
# Extract PR Number
57+
# Extract PR Number with fallback logic
5958
- bash: |
6059
echo "Extracting PR Number from Source Branch..."
6160
PR_NUMBER=$(echo $(System.PullRequest.SourceBranch) | grep -oP '(?<=refs/pull/)\d+(?=/merge)')
6261
63-
# Check if extraction succeeded
62+
# Handle case when PR_NUMBER is not extracted
6463
if [ -z "$PR_NUMBER" ]; then
65-
echo "##vso[task.logissue type=error] Failed to extract PR number. Please verify the branch name format: $(System.PullRequest.SourceBranch)"
66-
exit 1
64+
echo "##vso[task.logissue type=error] Failed to extract PR number. Branch format: $(System.PullRequest.SourceBranch)"
65+
exit 1
6766
fi
68-
6967
echo "Extracted PR Number: $PR_NUMBER"
7068
echo "##vso[task.setvariable variable=PR_NUMBER]$PR_NUMBER"
71-
displayName: Extract PR Number from Source Branch
72-
73-
# Generate TAG Variable
74-
- bash: |
75-
echo "Generating TAG variable..."
69+
70+
# Generate TAG variable
7671
TAG=pr-$(PR_NUMBER)-$(System.PullRequest.SourceCommitId)
7772
echo "Generated TAG: $TAG"
7873
echo "##vso[task.setvariable variable=TAG]$TAG"
79-
displayName: Generate Image Tag
74+
displayName: Extract PR Number and Generate TAG
75+
76+
- job: Build_Test_And_Push_Az_ARO_Extension
77+
dependsOn: Extract_PR_Number
78+
variables:
79+
TAG: $(TAG)
80+
pool:
81+
name: 1es-aro-ci-pool
82+
steps:
83+
- template: ./templates/template-checkout.yml
8084

8185
# Build and test the Az ARO Extension
8286
- script: |
@@ -90,9 +94,12 @@ stages:
9094
acrFQDN: 'arosvcdev.azurecr.io'
9195
repository: 'azext-aro'
9296
tag: $(TAG)
93-
pushLatest: true
97+
pushLatest: false
9498

9599
- job: Build_And_Test_RP_And_Portal
100+
dependsOn: Extract_PR_Number
101+
variables:
102+
TAG: $(TAG)
96103
pool:
97104
name: 1es-aro-ci-pool
98105
steps:
@@ -104,31 +111,18 @@ stages:
104111
DOCKER_BUILD_CI_ARGS="--load" make ci-rp VERSION=$(TAG)
105112
displayName: 🛠 Build & Test RP and Portal
106113
107-
# Publish test results
108-
- task: PublishTestResults@2
109-
displayName: 📊 Publish tests results
110-
inputs:
111-
testResultsFiles: $(System.DefaultWorkingDirectory)/report.xml
112-
condition: succeededOrFailed()
113-
114-
# Publish code coverage results
115-
- task: PublishCodeCoverageResults@2
116-
displayName: 📈 Publish code coverage
117-
inputs:
118-
codeCoverageTool: Cobertura
119-
summaryFileLocation: $(System.DefaultWorkingDirectory)/coverage.xml
120-
failIfCoverageEmpty: false
121-
condition: succeededOrFailed()
122-
123114
# Push the RP image to ACR
124115
- template: ./templates/template-acr-push.yml
125116
parameters:
126117
acrFQDN: 'arosvcdev.azurecr.io'
127118
repository: 'aro'
128119
tag: $(TAG)
129-
pushLatest: true
120+
pushLatest: false
130121

131122
- job: Build_And_Push_E2E_Image
123+
dependsOn: Extract_PR_Number
124+
variables:
125+
TAG: $(TAG)
132126
pool:
133127
name: 1es-aro-ci-pool
134128
steps:
@@ -146,7 +140,8 @@ stages:
146140
acrFQDN: 'arosvcdev.azurecr.io'
147141
repository: 'e2e'
148142
tag: $(TAG)
149-
pushLatest: true
143+
pushLatest: false
144+
150145

151146
- stage: E2E # E2E Stage using Docker Compose
152147
dependsOn: Containerized_CI

0 commit comments

Comments
 (0)