multiple pipeline triggered on a single commit
I have this yaml pipeline running on my hosted agent. My issue is when I commit the pipeline it triggers and runs multiple pipeline instead of only one pipeline. What changes I have to make so that the pipeline runs only once when I commit(trigger)
trigger:
- main
pool:
name: Default
steps:
- task: PowerShell@2
displayName: 'Create text files'
inputs:
targetType: 'inline'
script: |
Set-Content -Path $(Build.SourcesDirectory)/file1.txt -Value "Hello from file 1"
Set-Content -Path $(Build.SourcesDirectory)/file2.txt -Value "Hello from file 2"
From your screenshot and YAML code, the cause of the issue is that all pipelines have set the same Pipeline trigger:
trigger: main.In this case, when you do the commit operation in the main branch, it will trigger all pipelines which have set the pipeline trigger to main branch.
To solve this issue, you can refer to the following two situation:
1.If all Pipelines are using Same YAML file, you need to navigate to YAML Editor -> Triggers.
You can enable the option: Override the YAML continuous integration trigger from here. Then you can disable the trigger for other pipelines and enable the trigger for target pipeline.
2.If all pipelines are using Different YAML file, you can edit the YAML Pipelines to set the trigger to none and only set one pipeline to be triggered by main branch.
For example:
Or you can set the path filter in the trigger to exclude the files to trigger the pipeline.
For example:
For more detailed info, you can refer to the doc: Disabling the CI trigger