'My azure devops pipeline is triggered when my Bitbucket repo commits changes to non-code files

I am not sure if my question is clear enough. Here is some context. Our source code is in bitbucket. I have created an Azure DevOps pipeline that connects to bitbucket and pulls in the source code and builds a docker image and pushes it to an external registry. The pipeline is setup to be triggered when changes are committed to the bitbucket repo. This all works. The problem I have is that the pipeline also triggers if I change doesn't affect the build. For example, if I make a change to the docker-compose file, that won't affect the build, so it shouldn't trigger the pipeline in Azure DevOps, but it does.

Is there anyway around this?

Update: Jane Ma-MSFT is correct and using the Path filters resolved my issue. I added a Path filter Include Path=/src and it worked.

Additional information can be found Using Path filters in Build definition in Azure DevOps. It is from 2018 but still relevant. This link Multiple Project Deployment with Azure DevOps, shows how to use Path filters when you have a multi project Repo with shared projects.



Solution 1:[1]

In Azure DevOps, triggers cause a pipeline to run whenever you push an update to the specified branches or you push specified tags. That is, it doesn't matter whether the update affects the build, as long as you make the update, the pipeline will be triggered.

To avoid this, you can exclude certain paths. For example:

trigger:
  paths:
    include:
    - docs
    exclude:
    - docs/README.md

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jane Ma-MSFT