Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 289
vicch Avatar asked May 10 '19 12:05

vicch


2 Answers

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.

like image 170
Daniel Habenicht Avatar answered Oct 10 '22 07:10

Daniel Habenicht


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.

like image 43
Leo Liu-MSFT Avatar answered Oct 10 '22 05:10

Leo Liu-MSFT