I'm pretty new to Azure and pipelines, and I'm trying to trigger a pipeline from a pr in Azure. The repo lives in Github.
Here is the pipeline yaml: pipeline.yml
trigger: none # I turned this off for to stop push triggers (but they work fine)
pr:
  branches:
    include:
      - "*" # This does not trigger the pipeline 
stages:
  - stage: EchoTriggerStage
    displayName: Echoing trigger reason
    jobs:
      - job: A
        steps:
          - script: echo 'Build reason::::' $(Build.Reason)
            displayName: The build reason
# ... some more stages here triggered by PullRequests....
# ... some more stages here triggered by push (CI)....
The pr on Github looks like this:

However, the pipeline is not triggered, when the push triggers work just fine.
I have read in the docs but I can't see why this does not work.
The pipeline is working perfectly fine when I am triggering it through git push. However, when I try to trigger it with PR's from Github, nothing happens. In the code above, I tried turning off push triggers, and allow for all pr's to trigger the pipeline. Still nothing.
I do not want to delete the pipeline yet and create a new one.
I updated the yaml file to work as suggested underneath. Since the pipeline actually runs through a push command now, the rest of the details of the yaml file are not relevant and are left out.
-> Still no triggering of pipeline.
You have a mistake in your pipeline. It should be like this:
trigger: none # turned off for push
pr:
  - feature/automated-testing
steps:
- script: echo "PIPELINE IS TRIGGERED FROM PR"
Please change this
  - stage:
      - script: echo "PIPELINE IS TRIGGERED FROM PR"
to
  - stage:
    jobs:
    - job:
      steps:
      - script: echo "PIPELINE IS TRIGGERED FROM PR"
EDIT
I used your pipeline
trigger: none # I turned this off for to stop push triggers (but they work fine)
pr:
  branches:
    include:
      - "*" # This does not trigger the pipeline 
stages:
  - stage: EchoTriggerStage
    displayName: Echoing trigger reason
    jobs:
      - job: A
        steps:
          - script: echo 'Build reason::::' $(Build.Reason)
            displayName: The build reason
# ... some more stages here triggered by PullRequests....
# ... some more stages here triggered by push (CI)....
and all seems to be working.
Here is PR and here build for it

I didn't do that but you can try to enforce this via branch policy. TO do that please go to repo settings and then as follow:

The solution was to go to Azure Pipelines -> Edit pipeline -> Triggers -> Enable PR validation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With