I have a github repository called apprepo . In that there is a branch dev2 which i use it as the base branch.
I created another branch out of that dev3 made some changes to it. In the azure-pr-pipeline.yml the contents are as follows:
pr:
branches:
include:
- dev2 // include when PR is raised for merging to dev2 branch
stages:
- stage: PR
displayName: prBuild
jobs:
- job: DowndSecureFile
displayName: Build
steps:
- task: NodeTool@0
inputs:
versionSpec: '16.x'
displayName: 'Install Node.js'
- script: |
echo "workingdirectory " $(System.DefaultWorkingDirectory)
npm install
npm ci
npm audit fix
npm run build
Now when i make changes in dev3 and raise PR for merging to dev2,build gets triggered but the dev2 branch (base) is getting built instead of the dev3 branch where the changes are committed.
Can anyone please tell me, how to checkout the dev3 branch of the apprepo and only build that?
CodePudding user response:
The PR build should run for the PR merge branch (refs/pull/{PR Number}/merge), neither the target branch (dev2) nor the source branch (dev3).
If there is build triggered for the branch which is not the PR merge branch, ensure you have disabled the CI trigger on this YAML pipeline.
For example:
trigger: none // Disable the CI trigger.
pr:
branches:
include:
- dev2
By this way, the pipeline will be only triggered by PR, not by the CI trigger from the target branch and the source branch.