从 Jenkins 发布 Screenshot/PDF 的 SonarQube 分析结果到 Confluence
Publish the Screenshot/PDF of SonarQube Analysis Result from Jenkins to Confluence
我有一个 Jenkins 作业,只要 Bitbucket 存储库发生任何更改,它就会对从 Bitbucket 存储库中提取的代码调用 SonarQube 分析。目前,我可以使用 Confluence Publisher 插件将构建作业的 URL 作为评论发布到 Confluence。
我想知道是否有任何方法可以使用 Jenkins 截取 SonarQube 分析报告(就像在 SonarQube web UI 中一样)并将其直接发布到 Confluence? (这样用户就不需要使用URL去具体的Jenkins构建作业,然后获取SonarQube分析报告URL,然后导航到页面查看报告)
谢谢。
除了使用屏幕截图,您还可以从 Jenkins 向 SonarQube REST API(5.3 及更高版本)发送 curl 请求,以便在上传和分析代码后从质量门获取项目状态。您可能想要使用的端点是:/api/qualitygates/project_status?prjectKey=<projectKey>&branch=<branch>
根据网络 API 文档:
Get the quality gate status of a project or a Compute Engine task.
Either 'analysisId', 'projectId' or 'projectKey' must be provided
The different statuses returned are: OK, WARN, ERROR, NONE. The NONE status is returned when there is no quality gate associated with the analysis.
Returns an HTTP code 404 if the analysis associated with the task is not found or does not exist.
Requires one of the following permissions:
'Administer System'
'Administer' rights on the specified project
'Browse' on the specified project
获得这些结果后,您可以在 Confluence 中创建一个 Jenkins 用户,并让 Jenkins 发送一个 POST request 来创建一个页面或一条评论,其中包含获得的结果。
我有一个 Jenkins 作业,只要 Bitbucket 存储库发生任何更改,它就会对从 Bitbucket 存储库中提取的代码调用 SonarQube 分析。目前,我可以使用 Confluence Publisher 插件将构建作业的 URL 作为评论发布到 Confluence。
我想知道是否有任何方法可以使用 Jenkins 截取 SonarQube 分析报告(就像在 SonarQube web UI 中一样)并将其直接发布到 Confluence? (这样用户就不需要使用URL去具体的Jenkins构建作业,然后获取SonarQube分析报告URL,然后导航到页面查看报告)
谢谢。
除了使用屏幕截图,您还可以从 Jenkins 向 SonarQube REST API(5.3 及更高版本)发送 curl 请求,以便在上传和分析代码后从质量门获取项目状态。您可能想要使用的端点是:/api/qualitygates/project_status?prjectKey=<projectKey>&branch=<branch>
根据网络 API 文档:
Get the quality gate status of a project or a Compute Engine task. Either 'analysisId', 'projectId' or 'projectKey' must be provided The different statuses returned are: OK, WARN, ERROR, NONE. The NONE status is returned when there is no quality gate associated with the analysis. Returns an HTTP code 404 if the analysis associated with the task is not found or does not exist. Requires one of the following permissions: 'Administer System' 'Administer' rights on the specified project 'Browse' on the specified project
获得这些结果后,您可以在 Confluence 中创建一个 Jenkins 用户,并让 Jenkins 发送一个 POST request 来创建一个页面或一条评论,其中包含获得的结果。