Azure DevOps: CI Pipeline executing after merge

Viewed 1146

I have implemented a pipeline that will build and test the application once a Pull Request have been created. It works fine but it will run again once the PR is merged, and I only want it to run in the creation of a PR.

The Yaml fine goes like:

trigger:
- development

pool:
  vmImage: ubuntu-latest

variables:
  buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 3.1.000'
  inputs:
    version: 3.1.x
- task: DotNetCoreCLI@2
  displayName: 'Build the application'
  inputs:
    command: 'build'
    projects: 'example.csproj'
    configuration: 'Release'

- task: DotNetCoreCLI@2
  displayName: 'Run unit tests'
  inputs:
    command: 'test'
    projects: 'example.csproj'
    configuration: 'Release'
1 Answers

kraego is right.

You will have to remove the trigger section within your pipeline and configure a build validation branch policy for that build.

See here.

Related