azureazure-devopsazure-pipelines

Pull request NO_CI, [skip ci] not working


I have created a CI pipeline that is triggered when changes are pushed/merged into branch: "master".

trigger:
  batch: true
  branches:
    include:
      - master

pool: 
  vmImage: windows-latest

jobs:
  - job: Build
    condition: and(succeeded(),not(contains(variables['Build.SourceVersionMessage'], '[skip ci]'))) 
    steps:
      - script: echo "Hello world"!
        displayName: 'Echo Hello world'

      - script: echo "$(Build.SourceVersionMessage)"!
        displayName: 'Echo Build.SourceVersionMessage'

I want my pull request to not trigger this pipeline.

Is it possible to skip the CI pipeline if the pull request contains something like "[skip ci]"?

I know that something similar is possible when directly pushing into master, per the docs.

As you can see in the code above, I also tried a condition on the job, but it somehow always runs.


Solution

  • I am afraid this behavior is by design.

    As outlined in this document,

    Finally, after you merge the PR, Azure Pipelines will run the CI pipelines triggered by pushes to the target branch, even if some of the merged commits' messages or descriptions contain [skip ci] (or any of its variants).

    SKIPCI

    However, your pipeline should not reproduce the behavior. Based on your current pipeline YAML definition, which includes trigger: none, all CI triggers on the master branch should already be disabled. This means that the pipeline should not be triggered by any commit pushed to master, no matter it is a merge commit or a direct push.

    The only way it would trigger is if the YAML definition from the master branch explicitly includes trigger: - master, as shown in the above image.

    To further investigate, please verify:

    1. Whether the YAML trigger definition is being extracted from the .yml file in the master branch.
    2. Whether the YAML trigger settings have been overridden by UI settings.