sgoertzen / sonar-break-maven-plugin

Fail your maven build if sonar detects issues with the code
MIT License
10 stars 15 forks source link

How to use this plugin with sonarcloud.io #61

Open ec-wagner opened 5 years ago

ec-wagner commented 5 years ago

What needs to be done to make this plugin work with sonarcloud.io (SonarQube's cloud service)?

This es an example of how reports are send to sonarcloud.io:

mvn sonar:sonar \
  -Dsonar.projectKey=$SONARCLOUD_PROJECT_NAME \
  -Dsonar.organization=$SONARCLOUD_ORG \
  -Dsonar.host.url=https://sonarcloud.io \
  -Dsonar.login=$SONARCLOUD_KEY

Prerequisite to this is having the sonar scanner istalled.

Running mvn sonar:sonar sonar-break:sonar-break with this pom.xml

        <plugin>
            <groupId>com.github.sgoertzen</groupId>
            <artifactId>sonar-break-maven-plugin</artifactId>
            <version>1.2.5</version>
            <configuration>
                <sonarServer>https://sonarcloud.io</sonarServer>
                <sonarOrganization>$SONARCLOUD_ORG</sonarOrganization>
                <sonarProjectKey>$SONARCLOUD_PROJECT_NAME</sonarProjectKey>
                <sonarLogin>$SONARCLOUD_KEY</sonarLogin>
                <sonarLookBackSeconds>60</sonarLookBackSeconds>
                <waitForProcessingSeconds>2000</waitForProcessingSeconds>
            </configuration>
        </plugin>

results in

[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7.1:sonar
(default-cli) on project MY_PROJECT_NAME: Fail to download libraries from server:
java.net.ConnectException: Connection refused (Connection refused)
ec-wagner commented 5 years ago

updating sonar-maven-plugin leads to a different error

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar
(default-cli) on project MY_PROJECT_NAME: Unable to execute SonarQube:
Fail to download libraries from server: Failed to connect to localhost/0:0:0:0:0:0:0:1:9000
DusanBucan commented 3 years ago

Problem is that plugin make GET request on URL: https://sonarcloud.io/api/resources/index?resource=PROJECT_KEY&metrics=quality_gate_details

instead on this URL: https://sonarcloud.io/api/qualitygates/project_status?projectKey=PROJECT_KEY.