Skip to content

Commit

Permalink
Fix double-quote issues raised by shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
jacek-poreda-sonarsource committed May 18, 2021
1 parent fc54554 commit 69d13d6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions script/check-quality-gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ if [[ ! -f "$metadataFile" ]]; then
exit 1
fi

serverUrl="$(sed -n 's/serverUrl=\(.*\)/\1/p' ${metadataFile})"
ceTaskUrl="$(sed -n 's/ceTaskUrl=\(.*\)/\1/p' ${metadataFile})"
serverUrl="$(sed -n 's/serverUrl=\(.*\)/\1/p' "${metadataFile}")"
ceTaskUrl="$(sed -n 's/ceTaskUrl=\(.*\)/\1/p' "${metadataFile}")"

if [ -z "${serverUrl}" ] || [ -z "${ceTaskUrl}" ]; then
echo "Invalid report metadata file."
exit 1
fi

task="$(curl --silent --fail --show-error --user ${SONAR_TOKEN}: ${ceTaskUrl})"
task="$(curl --silent --fail --show-error --user "${SONAR_TOKEN}": "${ceTaskUrl}")"
status="$(jq -r '.task.status' <<< "$task")"

until [[ ${status} != "PENDING" && ${status} != "IN_PROGRESS" ]]; do
printf '.'
sleep 5s
task="$(curl --silent --fail --show-error --user ${SONAR_TOKEN}: ${ceTaskUrl})"
task="$(curl --silent --fail --show-error --user "${SONAR_TOKEN}": "${ceTaskUrl}")"
status="$(jq -r '.task.status' <<< "$task")"
done

analysisId="$(jq -r '.task.analysisId' <<< "${task}")"
qualityGateUrl="${serverUrl}/api/qualitygates/project_status?analysisId=${analysisId}"
qualityGateStatus="$(curl --silent --fail --show-error --user ${SONAR_TOKEN}: ${qualityGateUrl} | jq -r '.projectStatus.status')"
qualityGateStatus="$(curl --silent --fail --show-error --user "${SONAR_TOKEN}": "${qualityGateUrl}" | jq -r '.projectStatus.status')"

if [[ ${qualityGateStatus} == "OK" ]];then
success "Quality Gate has PASSED."
Expand Down

0 comments on commit 69d13d6

Please sign in to comment.