Reputation: 588
I'm fanatic about not getting the project quality out of control.
I understand that at certain cases warnings might make sense but i'm concerned that the number of warnings will increase over time.
I have an Azure DevOps build (gated commit) pipeline and i want to allow only 10 warnings so that at some point developers will have to address their warnings.
Is there a way to count the warnings and block the pipeline if the warnings count exceeds a certain number?
Thanx!
Upvotes: 10
Views: 4880
Reputation: 76790
Is there a way to count the warnings and block the pipeline if the warnings count exceeds a certain number?
The answer is yes.
There is a great extension to meet your needs:Build Quality Checks. It provides a wealth of build quality checks, and you can add these build quality checks to your build process.
There is an option Warning Threshold, which could be used to specify the maximum number of warnings. The build will fail if this number is exceeded.
And even if the policy breaks the build, you could still get test results as well as the compile output.
Upvotes: 7
Reputation: 58961
In your case, I would recommend treating warnings as error so that your gated commit will fail if the project contains warnings - here an example for dotnet core:
dotnet build /warnaserror
Developers still have the option to disable a warning in certain cases:
#pragma warning disable CS8632
// Here I do something that nullable references without context but I know what I do because...
#pragma warning restore CS8632
Upvotes: 3