简体   繁体   中英

SonarQube 6.7 LTS group permissions API doesn't working

I'm migrating SonarQube from 5.6 version to 6.7. I'm using SonarQube API with my Jenkins jobs and the problem is the API for groups permissions isn't working with 6.7 version...

I've tried manually with Postman (POST raw JSON) this :

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

The result returned is :

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

And it's the same if I use :

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

or

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

It's working with 6.5 verison and I've no idea where this problem may come from :(

@SonarQube developers team : can you fix thaaaat please ?

Send data as application/x-www-form-urlencoded or form-data. SonarQube Web API doesn't handle POST body in raw JSON format. See this question about Java ServletRequest to know more (Tomcat is used under the hood).

This is a piece of code to assign a project to a gate, using authentication and post. Mind the body and content-type!

// 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"
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM