9

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?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
vicch
  • 564
  • 3
  • 10
  • 25
  • Please don't put tags in the titles like `VSTS -`, Stackoverflow will prepend them automatically in search results. – jessehouwing May 13 '19 at 08:40
  • "and another build (BuildCode) when there's a change in the Code folder using the Path Filters on the Triggers tab" aren't you already triggering it ? – Blue Clouds Feb 01 '21 at 20:34
  • @BlueClouds, I am triggering it, but as I said in the question I only want to trigger it if there are changes ONLY in the Code folder – vicch Feb 06 '21 at 11:17

2 Answers2

37

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.

Daniel Habenicht
  • 2,133
  • 1
  • 15
  • 36
4

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.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135