Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonarqube 8.5 quality gate parameter componentKey #5882

Closed
1 of 3 tasks
blink38 opened this issue Nov 27, 2020 · 4 comments · Fixed by #6636
Closed
1 of 3 tasks

Sonarqube 8.5 quality gate parameter componentKey #5882

blink38 opened this issue Nov 27, 2020 · 4 comments · Fixed by #6636
Labels
question Support questions, usage questions, unconfirmed bugs, discussions, ideas

Comments

@blink38
Copy link

blink38 commented Nov 27, 2020

Are you experiencing an issue with...

🪲 Sonarqube 8.5 quality gate parameter componentKey

When retrieve the metrics from sonarqube instance, url used parameter named componentKey

GET /api/measures/component?componentKey=org.app%3AmyApp&metricKeys=alert_status

It seem that the parameter componentKey have been renamed to component in sonarqube.

So, it should be :

GET /api/measures/component?component=org.app%3AmyApp&metricKeys=alert_status

🔗 Link to the badge

💡 Possible Solution

In services/sonar/sonar-base.js, rename componentKey to component
qs = { componentKey: component, metricKeys: metricName, }

to

qs = { component: component, metricKeys: metricName, }

@blink38 blink38 added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Nov 27, 2020
@calebcartwright
Copy link
Member

Thanks for reaching out @blink38, could you please provide some additional context? Is there a problem you are seeing with the badges? Is there any release notes from Sonar Source announcing breaking API changes?

@blink38
Copy link
Author

blink38 commented Nov 27, 2020

When selecting Analysis > Sonar Quality Gate :

image

The output is a badge with "invalid" [text.]
quality-gate-invalid

The URL called by shields.io is :
http://mysonar/api/measures/component?componentKey=org.app%3AmyApp&metricKeys=alert_status

The response of the url is :

{"errors":[{"msg":"The 'component' parameter is missing"}]}

Now, I made some change in services/sonar/sonar-base.js :

--- sonar-base.js.origin        2020-11-27 20:09:30.000000000 +0100
+++ sonar-base.js       2020-11-27 20:13:13.000000000 +0100
@@ -71,7 +71,7 @@
       schema = modernSchema
       url = `${server}/api/measures/component`
       qs = {
-        componentKey: component,
+        component: component,
         metricKeys: metricName,
       }
     }

The URL called is now :
http://mysonar/api/measures/component?component=org.app%3AmyApp&metricKeys=alert_status

The response of the url is :

{"component":{"id": ... ,"qualifier":"TRK","measures":[{"metric":"alert_status","value":"OK"}]}}

And the badge text output is "passed".
quality-gate-passed


On this page : https://gazelle.ihe.net/sonar/web_api/api/measures?deprecated=true, if you look at the parameters of GET api/measures/component, you will read that the componentKey is deprecated since 6.6

This issue https://jira.sonarsource.com/browse/SONAR-9676 discuss about renaming componentKey to component, fixed in 6.6

@jgangemi
Copy link

jgangemi commented Feb 2, 2021

i am also experiencing this issue, but with version 8.4.2

@chkpnt
Copy link

chkpnt commented Jul 24, 2021

I can confirm this issue with SonarQube 8.9.1 (LTS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Support questions, usage questions, unconfirmed bugs, discussions, ideas
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants