SonarQube 6.7 LTS组权限API不起作用

问题描述 投票:5回答:2

我正在将SonarQube从5.6版迁移到6.7版。我正在使用SonarQube API和我的Jenkins作业,问题是群组权限的API不适用于6.7版本...

我已尝试手动使用Postman(POST原始JSON):

{
    "groupName": "project-name-admin",
    "permission": "admin",
    "projectKey": "project-name"
}

返回的结果是:

{
    "errors": [
        {
            "msg": "Group name or group id must be provided"
        }
    ]
}

如果我使用它也是一样的:

{
    "groupId": 53,
    "permission": "admin",
    "projectKey": "project-name"
}

要么

{
    "groupId": 53,
    "groupName": "project-name-admin",
    "permission": "admin",
    "projectKey": "project-name"
}

它正在使用6.5版本,我不知道这个问题可能来自哪里:(

@SonarQube开发团队:你能修好thaaaat吗?

sonarqube sonarqube-api
2个回答
2
投票

application/x-www-form-urlencoded或form-data发送数据。 SonarQube Web API不以原始JSON格式处理POST正文。有关Java ServletRequest的信息,请参阅此question以了解更多信息(Tomcat在引擎盖下使用)。


0
投票

这是使用身份验证和发布将项目分配到门的一段代码。注意身体和内容类型!

// format post, sonarqube only knows form encoded
def body = sprintf("gateId=%s&projectKey=%s", ["${gateId}", "${projectKey}"])

// post to associate project with gate
result = httpRequest (
    consoleLogResponseBody: true,
    authentication: '<My Jenkins Credential>', 
    contentType: 'APPLICATION_FORM',
    httpMode: 'POST', 
    ignoreSslErrors: true, 
    requestBody: "${body}", 
    url: "http://<sonarqube.url>/api/qualitygates/select"
)
© www.soinside.com 2019 - 2024. All rights reserved.