@@ -3,12 +3,8 @@ pr:
|
|||||||
branches:
|
branches:
|
||||||
include:
|
include:
|
||||||
- develop
|
- develop
|
||||||
paths:
|
|
||||||
include:
|
|
||||||
- projects/*
|
|
||||||
- shared/*
|
|
||||||
drafts: false
|
drafts: false
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
- group: internal
|
- group: internal
|
||||||
- name: REPOSITORY_NAME
|
- name: REPOSITORY_NAME
|
||||||
@@ -25,17 +21,46 @@ variables:
|
|||||||
value: 'pull_request'
|
value: 'pull_request'
|
||||||
- name: GH_PAT
|
- name: GH_PAT
|
||||||
value: '$(svc_acc_org_secret)'
|
value: '$(svc_acc_org_secret)'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- job: Trigger_Pipeline
|
- job: Determine_Changes
|
||||||
displayName: 'Trigger Pipeline'
|
displayName: 'Check Changed Files'
|
||||||
pool: rocm-ci-caller
|
pool: rocm-ci-caller
|
||||||
steps:
|
steps:
|
||||||
- checkout: none
|
- checkout: self
|
||||||
- script: |
|
- script: |
|
||||||
|
echo "## Detecting file changes in PR #$(PR_NUM)"
|
||||||
|
git fetch origin $(BASE_REF)
|
||||||
|
git diff --name-only origin/$(BASE_REF)...HEAD > changed_files.txt
|
||||||
|
echo "Changed files:"
|
||||||
|
cat changed_files.txt
|
||||||
|
|
||||||
|
MATCH_FOUND=false
|
||||||
|
while read file; do
|
||||||
|
if [[ "$file" == projects/* || "$file" == shared/* ]]; then
|
||||||
|
MATCH_FOUND=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done < changed_files.txt
|
||||||
|
|
||||||
|
echo "##vso[task.setvariable variable=match_found]$MATCH_FOUND"
|
||||||
|
displayName: Detect path changes
|
||||||
|
|
||||||
|
- job: Trigger_Pipeline
|
||||||
|
displayName: 'Trigger Pipeline or Skip'
|
||||||
|
dependsOn: Determine_Changes
|
||||||
|
condition: succeeded()
|
||||||
|
pool: rocm-ci-caller
|
||||||
|
steps:
|
||||||
|
- checkout: none
|
||||||
|
|
||||||
|
- ${{ if eq(dependencies.Determine_Changes.outputs['Determine_Changes.match_found'], 'true') }}:
|
||||||
|
- script: |
|
||||||
rm -rf $(repo_name)
|
rm -rf $(repo_name)
|
||||||
git clone $(gh_repo)
|
git clone $(gh_repo)
|
||||||
displayName: Checkout Code
|
displayName: Checkout Code
|
||||||
- script: |
|
|
||||||
|
- script: |
|
||||||
set -e
|
set -e
|
||||||
echo "Calling jenkins_api.py for PR #$(PR_NUM)"
|
echo "Calling jenkins_api.py for PR #$(PR_NUM)"
|
||||||
cd $(repo_name)
|
cd $(repo_name)
|
||||||
@@ -57,6 +82,22 @@ jobs:
|
|||||||
-ghpat '$(GH_PAT)' \
|
-ghpat '$(GH_PAT)' \
|
||||||
-br '$(BASE_REF)' \
|
-br '$(BASE_REF)' \
|
||||||
-et '$(EVENT_TYPE)'" > /dev/null 2>&1
|
-et '$(EVENT_TYPE)'" > /dev/null 2>&1
|
||||||
displayName: Invoke jenkins_api.py in Docker
|
displayName: Invoke jenkins_api.py in Docker
|
||||||
env:
|
env:
|
||||||
svc_acc_org_secret: $(svc_acc_org_secret)
|
svc_acc_org_secret: $(svc_acc_org_secret)
|
||||||
|
|
||||||
|
- ${{ if ne(dependencies.Determine_Changes.outputs['Determine_Changes.match_found'], 'true') }}:
|
||||||
|
- script: |
|
||||||
|
echo "Changes outside monitored paths. Skipping Jenkins trigger."
|
||||||
|
echo "Sending success status for PSDB..."
|
||||||
|
gh api repos/$(REPOSITORY_NAME)/statuses/$(HEAD_SHA) \
|
||||||
|
-H "Authorization: token $(GH_PAT)" \
|
||||||
|
-f state=success \
|
||||||
|
-f context="PSDB" \
|
||||||
|
-f description="PSDB skipped"
|
||||||
|
gh api repos/$(REPOSITORY_NAME)/statuses/$(HEAD_SHA) \
|
||||||
|
-H "Authorization: token $(GH_PAT)" \
|
||||||
|
-f state=success \
|
||||||
|
-f context="psdb-test" \
|
||||||
|
-f description="psdb-test skipped"
|
||||||
|
displayName: Send Skipped Status
|
||||||
|
|||||||
Reference in New Issue
Block a user