'Conditions - Differentiate pull request and pull request merge

Let's say I have a pipeline my-pipeline which 1) Install dependencies 2) Test my application.

I set up a build validation policy which triggers my-pipeline upon creation of a pull request.

Once the pull request is approved and merged, my-pipeline is triggered again.

Questions

Is there a way to differentiate the creation of the PR and the merged of the PR within my yaml file, so I can use conditions to trigger some scripts on creation but not on merge. Something similar to condition: and(succeeded(), startsWith(variables['build.reason'], 'PullRequest'))

For instance, I would trigger test on PR creation but not after the merge



Sources

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

Source: Stack Overflow

Solution Source