0
votes

I created a project using SonarQube web api and now I'm trying to analyze the project.
I found this

POST api/project_analyses/create_event

When I tried this service I got this response

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

This have two required parameters: name and analysis (analysis key)
Where can I get the analysis key?
Is it possible to analyze my project with this service?
I have also read about I can use the command sonar-scanner but I would rather use the web api

1
well the sonarqube server is not doing the analysis, you will need a sonar scanner :D - Simon Schrottner

1 Answers

4
votes

You have a basic misunderstanding in how Sonarqube is working, there are two parts working together.

Scanner vs. Server

first the Sonarqube-server, which is holding the configuration of projects, quality gates and quality profiles (aka rulesets). The purpose of the server is the displaying part and managing part. It will show you all your issues, and it will allow you to manage it. BUT it will not analyse your source code.

second the scanner. This is the part which is analyzing your source code. It will ask the server for the quality profile and its rules. It will go through your configured files and try to look for those issues and it will generate a report, which will be commited to the sonarqube-server to be evaluated and displayed

Why is there an api?

well first of all, the server has to get some information from the scanner too, it might be in the report too, but for that i do not have enough knowledge -> but the api is also there for provisioning, creating a project from the outside, pre configuring it, with the right settings, before hitting the first analysis.

What is my api call doing?

this is just for creating Events on the timeline, this will not trigger an build or anything, but it allows you to "tag" a certain analysis. This allows you to create some correlation between other events, which might not be part of your sonarqube instalation at all. you can find them in the acticity tab of a project.

little disclaimer

i just want to clarify, that this is, how i understood, this is working (and it works for my projects) - i might have some errors in my description, which are not 100% accurate and i am sorry for that, but i am sure, that if i put an error here, one of the sonarsource guys and girls will complain, and provide an sufficient enough explanation :D