Enable continuous integration on ALL branches in Azure DevOps

I am using SonarCloud on a .NET project in Azure DevOps. I’m using the “.NET Core with SonarCloud” template. I need to make sure all of the code is scanned on all branches automatically using continuous integration.

When I enable Continuous Integration in Azure DevOps by checking the box, I then need to manually add each branch to the branch filters list.

Surely there must be a way to automatically scan on all branches. For instance, if I could edit the YAML file it would start with:

trigger:
branches:
include:
- ‘*’

Am I missing something here? Thanks!

Hi @benwilson999 welcome to the community !

Well it’s more a problem of Azure configuration here more than SonarCloud, but i’ll try to help :wink:

Continuous integration using “classic” editor is indeed not the best when it comes to configure all branches. (here the related Microsoft doc : Building multiple branches - Azure Pipelines | Microsoft Docs)

That being said, if you really want to use YAML, we provide a set of YAML templates, mirroring the one for the classic editor, you can find them here : sonar-scanner-vsts/net-core-sonarcloud.yml at master · SonarSource/sonar-scanner-vsts · GitHub

HTH,
Mickaël

Hi Mickaël,

Thanks for your quick response! I will go ahead and use the YAML files you linked and change it to trigger on all branches.

Cheers,
Ben

Hi @benwilson999 ,

When you set up the branch filter for CI in Azure DevOps, you can type “*” into the dropdown box instead of selecting a branch. Not the best UI, but this works:
image

Alternatively, create one dummy branch and set this to Exclude. Then all other current and future branches are included.

1 Like

Thanks Chris!

I wouldn’t have thought of that myself. That’s super helpful.