Build Breaker Plugin with SonarQube 5.2

后端 未结 4 1346
遥遥无期
遥遥无期 2020-12-28 21:22

It seems like the Build Breaker Plugin is no longer compatible with SonarQube 5.2. Is there any alternative to have a (VSO) build fail if a Sonar gate is not fulfilled or ar

相关标签:
4条回答
  • 2020-12-28 21:34

    In SonarQube 5.2 we found alternative way in usage of Web Service /api/events.


    Request example:

    https://<sq-host>/api/events?categories=Alert&resource=<project_key>
    

    Response example:

    <events>
        <event>
            <id>50411</id>
            <name>Red (was Green)</name>
            <resourceKey>project_key</resourceKey>
            <category>Alert</category>
            <date>2015-09-29T22:38:44+0200</date>
            <description>New Critical issues > 0 since previous analysis (2015 Sep 23), New Major issues > 0 since previous analysis (2015 Sep 23), New issues > 0 since previous analysis (2015 Sep 23)</description>
        </event>
        ....
    </events>
    

    Detecting RED status of the project:

    To verify RED status you will need to find event with highest id value in events list from response and then verify that name of this event is starting from Red and if you will find it you will need to fail build.

    Such verification can be done just on CI server using additional command line step after SQ step or it can be done from build automation system like Maven or Gradle.


    We didn't implement such workaround yet in our project, just because of lack free time, but we will do this in near future.

    Proposed solution should be used only as workaround until issue SONAR-6763 will be done.

    0 讨论(0)
  • 2020-12-28 21:34

    With SonarQube 5.3 a new Quality Gates Web Service was introduced which could be called and used to break the build.

    To break the CI build for a failed Quality Gate, use WS API calls in a loop to wait until processing is finished, and then check Quality Gate web service:

    • call the analysis's ceTaskUrl and examine the "status" value:
      • PENDING or IN_PROGRESS - check again later
      • FAILED or CANCELED - break the build?
      • SUCCESS - move forward
    • call Quality Gate web service for status

    I've also added an issue to enhance the VSTS Tasks with an option to automatically call this service.

    Update: A recent PR added this feature to the VSTS Task (not released yet)

    0 讨论(0)
  • 2020-12-28 21:39

    There is not (for now) any plugin which will break build when Quality Gate did't pass on SonarQube 5.2.

    But for SonarQube 5.3+ you can again use Build Breaker plugin.


    From mailing list:

    Breaking the build in SonarQube 5.2 (21/Oct/2015)

    Fabrice Bellingrad: The Build Breaker Plugin won't be available for SQ 5.2+. The idea is to develop a core feature to answer the use cases previously covered by this plugin. This is what we call the "what if" feature => https://jira.sonarsource.com/browse/SONAR-6763

    This issue SONAR-6763 is planned for SonarQube 6.X.

    0 讨论(0)
  • 2020-12-28 21:43

    You can now use the SonarQube Build Breaker Plugin with version SonarQube version 5.3+.

    0 讨论(0)
提交回复
热议问题