Trigger build only if no changes on specified folder in Azure Pipelines

10,591

Solution 1

What I'd like to do is trigger the BuildCode build if there are changes only in the Code folder. Is there a way to do this?

I am afraid there is no such way to do this.

As I understand you, you want trigger the BuildCode build if there are changes only in the Code folder. That means if both folders have changed after a push or completed pull request, it will not trigger the BuildCode build. If I understand you correct, you should not have any way to do this.

When we enable the option Enable continuous integration, Azure Devops will trigger build after we submit any change in the branch/folder to ensure that our modifications are correct. This is the original intention of this function being designed.

If both folders have changed but only build one folder, which does not match the original intention of this function. And we could bypass the setting Enable continuous integration for the BuildCode folder.

Hope this helps.

Solution 2

Azure Devops does support this case. If you are using the following folder structure

📁 rootfolder
|-📁 scripts
|-📁 code

Just create a azure-pipelines.yml for each path you want to build and add the following lines at the top:

trigger:
  paths:
    include:
    - path/to/include/*

# for exampple: 
#   - scripts/*

# You can also exlude specific files
    exclude:
    - docs/README.md

Read more at Microsofts Documentation. An example can be found here.

Share:
10,591
vicch
Author by

vicch

.net

Updated on July 22, 2022

Comments

  • vicch
    vicch almost 2 years

    I have a repo with two subfolders in Visual Studio Team Services: Code and Scripts. I am now triggering one build (BuildScripts) when there's a change in the Scripts folder and another build (BuildCode) when there's a change in the Code folder using the Path Filters on the Triggers tab. If both folders have changed after a push or completed pull request then both builds will be triggered.

    What I'd like to do is trigger the BuildCode build if there are changes only in the Code folder. Is there a way to do this?

  • Leo Liu
    Leo Liu almost 5 years
    This is not what the OP wants.
  • Daniel Habenicht
    Daniel Habenicht almost 5 years
    Jep, seems like it was a little bit late yesterday. Can you make a little change to you answer so that I can upvote your answer again? Sry, and thanks for your comment.