azure-devopscontinuous-integrationazure-pipelinesazure-pipelines-yaml

Trigger Azure DevOps CI Build when pushing a branch with a certain name


When we shifted our CI Build from classic to YAML, we wanted the CI only to run when the target is our master branch. So right now, if you create a PR and push changes, it will run the CI as expected.

This is the trigger in our CI YAML:

trigger:
  batch: true
  branches:
    include:
      - master

Now, I thought I could just add 'releases/*' to the triggers and it would automatically start ab build, but this does not work:

trigger:
  batch: true
  branches:
    include:
      - master
      - releases/*

I also tried putting it in parenthesis "releases/*" and including the full path like refs/head/releases/\*, but nothing works.

I've read here that trigger should be correct to trigger the pipeline and pr should only trigger on pull requests. I don't see the problem. Any hints?


Solution

  • Try removing batch: true from your trigger.

    As per Batching CI runs (emphasis mine):

    If you set batch to true, when a pipeline is running, the system waits until the run is completed, then starts another run with all changes that have not yet been built.

    Also:

    If the pipeline has multiple jobs and stages, then the first run should still reach a terminal state by completing or skipping all its jobs and stages before the second run can start. For this reason, you must exercise caution when using this feature in a pipeline with multiple stages or approvals.