使用 SonarQube Web api 分析项目 [英] Analyze project with SonarQube web api

查看:33
本文介绍了使用 SonarQube Web api 分析项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 SonarQube web api 创建了一个项目,现在我正在尝试分析该项目.
我找到了这个

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"
        }
    ]
}

这有两个必需参数:nameanalysis(分析键)
我在哪里可以获得分析密钥?
是否可以使用此服务分析我的项目?
我也读过我可以使用命令 sonar-scanner 但我更愿意使用 web api

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

推荐答案

你对 Sonarqube 的工作原理有一个基本的误解,有两个部分协同工作.

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

首先是 Sonarqube 服务器,它保存项目配置、质量门和质量配置文件(又名规则集).服务器的用途是显示部分和管理部分.它将向您展示所有问题,并允许您管理它.但它不会分析您的源代码.

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.

第二个扫描仪.这是分析您的源代码的部分.它将向服务器询问质量配置文件及其规则.它将检查您配置的文件并尝试查找这些问题并生成报告,该报告将提交给 sonarqube-server 进行评估和显示

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

首先,服务器也必须从扫描仪获取一些信息,它也可能在报告中,但为此我没有足够的知识 -> 但 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.

这只是为了在时间线上创建事件,这不会触发构建或任何事情,但它允许您标记"某个分析.这允许您在其他事件之间创建一些关联,这可能根本不是您的声纳安装的一部分.您可以在项目的活动选项卡中找到它们.

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.

我只是想澄清一下,这是我的理解,这是有效的(它适用于我的项目)-我的描述中可能有一些错误,这些错误不是 100% 准确的,对此我深表歉意,但我敢肯定,如果我在此处输入错误,声纳源中的一个人和女孩会抱怨,并提供足够充分的解释:D

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

这篇关于使用 SonarQube Web api 分析项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆