Search code examples
tfssonarqubesonar-runnersonarqube-scan

Sonarquberunner check c# code


I may introduce a custom rule that checks our code whether it contains a deprecated using.

using foo.bar;

class FooClass {

Is there a possibility by custom rules or Sonar itself to check this code and fail the build due to usage of deprecated package foo.bar?


Solution

  • I'm going to work backward:

    • You can fail the build with a Jenkins pipeline
    • if your analysis fails the Quality Gate.
    • You can't fail the Quality Gate for issues from a specific rule, but you can fail it for new issues of a certain severity

    So I would recommend that you set add your new rule to your Quality Profile at Blocker severity (after all, you want it to block the build), set a quality gate error condition on New Blocker Issues and set up your Jenkins pipeline to respond appropriately.

    If you're not using Jenkins, or not using Pipelines, there is also the Build Breaker plugin, altho its use is not recommended.