Reputation: 1
I am using Sonarqube10.6 and I am trying to get these rating values- new_reliability_rating | new_security_rating | new_maintainability_rating | new_security_hotspots_reviewed
in this analysis_ratings.txt
file using this api /api/qualitygates/project_status
but i am not getting any value.
Here is my coplete code-
if (env.TECH == 'Java_Gradle') {
sh """
set +x
sudo chmod +x gradlew
mv build.gradle.staging build.gradle
./gradlew sonar \
-Dsonar.projectKey=project-java-gradle \
-Dsonar.host.url=sonar_server_url \
-Dsonar.token=token_number \
-Dsonar.projectName="${env.REPO_NAME}"
sleep 120
sudo java -jar /app/sonar/sonar-cnes-report-5.0.0.jar -t token_number -p project-java-gradle -m -c -e -f -s sonar_server_url -o /app/sonar/report
sudo curl -u ${SONAR_USER}:${SONAR_PASSWORD} "sonar_server_url/api/qualitygates/project_status?projectKey=project-java-gradle" | jq -r '.projectStatus.status' > /app/qualitygate_status.txt
sudo curl -u ${SONAR_USER}:${SONAR_PASSWORD} "sonar_server_url/api/qualitygates/project_status?projectKey=project-java-gradle" | jq -r '.projectStatus.conditions | map(select(.metricKey | test("new_reliability_rating|new_security_rating|new_maintainability_rating|new_security_hotspots_reviewed"))) | .[] | .actualValue' > /app/analysis_ratings.txt
set -x
"""
}
In this code where i am scanning java_gradle application in sonarqube10.6
server after scanning generate a report for that using cnes report-5.0 then retrieves the quality gate status for that project from a SonarQube server using an authenticated API request
and writes this status to a file qulitygate_status.txt
And again using the same api processes the JSON response to extract the actualValue
of specific metrics (new_reliability_rating
, new_security_rating
, new_maintainability_rating
, and new_security_hotspots_reviewed
) and writes these values to a file analysis_ratings.txt But not getting these values.
When I run this api on to my server to get the json data it gives me only this.
command:
sudo curl -u ${SONAR_USER}:${SONAR_PASSWORD} "http://10.0.5.156:9000/api/qualitygates/project_status?projectKey=dynamic-project-java-gradle" | jq .
Here is the output
{
"projectStatus": {
"status": "ERROR",
"conditions": [
{
"status": "ERROR",
"metricKey": "new_coverage",
"comparator": "LT",
"errorThreshold": "80",
"actualValue": "0.0"
},
{
"status": "OK",
"metricKey": "new_duplicated_lines_density",
"comparator": "GT",
"errorThreshold": "3",
"actualValue": "2.79341"
},
{
"status": "ERROR",
"metricKey": "new_security_hotspots_reviewed",
"comparator": "LT",
"errorThreshold": "100",
"actualValue": "0.0"
},
{
"status": "ERROR",
"metricKey": "new_violations",
"comparator": "GT",
"errorThreshold": "0",
"actualValue": "12"
}
],
"ignoredConditions": false,
"period": {
"mode": "PREVIOUS_VERSION",
"date": "2024-07-04T07:44:16+0000"
},
"caycStatus": "over-compliant"
}
}
But I was also expecting these values- new_reliability_rating | new_security_rating | new_maintainability_rating | new_security_hotspots_reviewed
in the json data
Upvotes: 0
Views: 132