diff --git a/CHANGELOG.md b/CHANGELOG.md index dbcda0919..994ebb3a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Fixed - Fix SonarQube quality gate report to use the pull request or branch in scope ([#1016](https://github.com/opendevstack/ods-jenkins-shared-library/issues/1016)) +- CURL command fix for the sonarqube quality gate report retrieval ([#1020](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1020)) - Fix typos in `build.gradle` ([#1012](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1012)) ## [4.3.0] - 2023-07-03 diff --git a/src/org/ods/services/SonarQubeService.groovy b/src/org/ods/services/SonarQubeService.groovy index 152134251..0e2a45a76 100644 --- a/src/org/ods/services/SonarQubeService.groovy +++ b/src/org/ods/services/SonarQubeService.groovy @@ -87,15 +87,16 @@ class SonarQubeService { String gitBranch, String bitbucketPullRequestKey) { withSonarServerConfig { hostUrl, authToken -> - def getStatusUrl = "${hostUrl}/api/qualitygates/project_status?projectKey=${projectKey}" + def getStatusUrl = "${hostUrl}/api/qualitygates/project_status" + def urlEncodingFlags = "--data-urlencode projectKey=${projectKey}" if (bitbucketPullRequestKey && (sonarQubeEdition != 'community')) { - getStatusUrl += "&pullRequest=" << bitbucketPullRequestKey + urlEncodingFlags += " --data-urlencode pullRequest=${bitbucketPullRequestKey}" } else if (sonarQubeEdition != 'community') { - getStatusUrl += "&branch=" << gitBranch + urlEncodingFlags += " --data-urlencode branch=${gitBranch}" } script.sh( label: 'Get status of quality gate', - script: "curl -s -u ${authToken}: ${getStatusUrl}", + script: "curl -s -u ${authToken}: --url ${getStatusUrl} ${urlEncodingFlags}", returnStdout: true ) }