'How can i trigger a build in Azure DevOpswhen a pull request is made in Github

I'm using Azure DevOps for pipelines and GitHub as my repo. I want to trigger a build in Azure DevOps when a pull request is made.

I have two branches in GitHub: master and test.

When I update test and create a pull request I want Azure DevOps to automatically build the pipeline and run it... how can i do this ?

I tried the below but nothing happens

pr:

  • main

trigger:

  • main

pool: vmImage: ubuntu-latest



Solution 1:[1]

You can add a pr trigger in your yaml pipeline:

pr:
- master

Solution 2:[2]

this worked for me in the end :

**pr:
  branches:
    include:
    - '*'** 
pool:
  vmImage: ubuntu-latest

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shayki Abramczyk
Solution 2 itye1970