Cedervall
Cedervall

Reputation: 1939

Azure DevOps Build Pipeline triggers on pull request

I have a .Net project that uses the Azure DevOps pipelines. The setup is that I have a build pipeline that creates an artifact. The artifact then automatically gets published through the release pipeline. This is working perfectly.

The problem is after I turned on the policy Build Validation, pull requests now triggers the build pipeline which then triggers the release pipeline. So every pull requests gets published. The build step is correct, but the release should not happen. The pre-deployment trigger "Pull request deployment" is disabled.

What I did to try to solve this is that I added a condition to the build step where the artifact gets created. So pull requests does not create artifacts, while merges does. This also works as intended. However, the release pipe still gets triggered, but this time without an artifact (which fails the pipe).

TLDR:
Release pipe triggers on pull requests, settings for this behavior is off. WTD?

My CI/CD settings:

CD trigger

Deployment conditions

Upvotes: 2

Views: 10251

Answers (2)

Alexandre
Alexandre

Reputation: 1232

What we have here is that we've set up build pipelines tied to YAML files stored in the repository, together with source code. And release pipelines have their Source set up to each of the build pipelines.

This is part of the Master Build:

trigger:
  batch: false
  branches:
    include:
    - master

And this is part of the Pull Request Build:

trigger: none

pr:
- master

We have Release pipelines for each of the Source builds, having Pull Request triggers enabled in one of them only, but you can have only one for your master artifacts, so PRs won't be published.

Upvotes: 0

Shamrai Aleksander
Shamrai Aleksander

Reputation: 16133

Your release triggers on any of your builds and branches (PR also has a branch). You have to add the branch filter: Continuous deployment triggers. Restrict your filter with the master branch or any other. Also, you can define 2 build definitions:

  1. A pipeline to validate your pull requests without linked releases.
  2. CI pipeline that triggers a release.

Additionally, I think, this is a bug. Because the PR trigger is not enabled. Let's check dev community comments: https://developercommunity.visualstudio.com/content/problem/1292039/release-pipelines-ignore-pull-request-settings.html

Upvotes: 1

Related Questions