Haufe-Lexware / gocd-plugins

A collection of our OSS plugins for use with Go.CD
Apache License 2.0
36 stars 34 forks source link

I am receiving an error related to org.json when trying to use the latest SonarQube QualityGate plugin #20

Open eravenelle opened 7 years ago

eravenelle commented 7 years ago

I am running SonarQube Version 6.5 (build 27846) on Amazon Linux and GoVersion: 17.10.0 (5380-05598d88fd4dabdde1184faa4fbffc5f9406d0dc) also running on Amazon Linux.

The error message:

[go] Task: Plugin with ID: sonar.quality.gate.plugin [SonarQube Quality Gate Plugin] configuration setting 'SonarProjectKey' is 'org.company.project:Project' [SonarQube Quality Gate Plugin] configuration setting 'StageName' is '' [SonarQube Quality Gate Plugin] configuration setting 'JobCounter' is '' [SonarQube Quality Gate Plugin] configuration setting 'JobName' is '' [SonarQube Quality Gate Plugin] configuration setting 'IssueTypeFail' is 'warning' [SonarQube Quality Gate Plugin] configuration setting 'SonarApiUrl' is 'http://10.71.10.112:9000' [SonarQube Quality Gate Plugin] checking quality gate result for: org.company.project:Project [SonarQube Quality Gate Plugin] API Url: http://10.71.10.112:9000 [SonarQube Quality Gate Plugin] Fail if: warning [SonarQube Quality Gate Plugin] Error during get or parse of quality gate result. Please check if a quality gate is defined A JSONArray text must start with '[' at 1 [character 2 line 1] class org.json.JSONException declares multiple JSON fields named cause

bradeac commented 7 years ago

Hi,

I think we can solve this if you can post the value of JSONArray (or at least the beginning).

There's a high possibility that the JSON you get isn't formatted correctly, but we've also seen other problems when we got this error.

Have a nice day.

eravenelle commented 7 years ago

@bradeac I don't know what JSONArray is returning because this is happening between the plugin and SonarQube. Is SonarQube's API response returning malformed JSON data? How would I check this?

bradeac commented 7 years ago

Well, there is a way. 1st option: you can log stuff to the pipeline console. For this, you have to add some lines of code, rebuild the plugin and the new plugin into the 'plugins' folder of your go.cd server.

The JSONArray type is used in 'SonarClient' and in 'SonarParser' classes. But, the 'log' method is only available in 'SonarTaskExecutor' class. You can find usage examples of it in this class.

I am thinking that maybe you should log the 'sonarClient' and the 'parser' objects, This way we can see where it's failing.

If I gave you too little details and don't know how to do some of this, just come back with a reply.

2nd option: debug the plugin step by step. This is a bit trickier, you have to have a debug-enabled go.cd agent, run the plugin on that agent and attach to that process on the agent.

prem4747 commented 5 years ago

Hi @bradeac , I am getting the same error as above with Gocd version 19.7.0 (9567-727ea9db824eb6971170ac2a886ff1072ff5a235)

Can you please let me know if this issue has been resolved?

bradeac commented 5 years ago

Hi @prem4747,

I'm not quite sure what the status is or if this is still maintained, I haven't worked on this for the last two years.

@nicholasdille, @markus2810 maybe you can help here.