chore: remove comment
This commit is contained in:
parent
f374843ab8
commit
114b4376ea
1 changed files with 0 additions and 31 deletions
31
sonar.sh
31
sonar.sh
|
@ -1,40 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if ! command -v jq > /dev/null; then
|
|
||||||
mkdir -p /tmp/bin
|
|
||||||
wget -q https://nexus.nyyu.dev/repository/files/bin/jq-linux64 -O /tmp/bin/jq
|
|
||||||
chmod +x /tmp/bin/jq
|
|
||||||
export PATH="/tmp/bin:$PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sonarOpts=(-Dsonar.branch.name="${CI_COMMIT_BRANCH}")
|
sonarOpts=(-Dsonar.branch.name="${CI_COMMIT_BRANCH}")
|
||||||
if [[ -n "${CI_COMMIT_PULL_REQUEST}" ]]; then
|
if [[ -n "${CI_COMMIT_PULL_REQUEST}" ]]; then
|
||||||
sonarOpts=(-Dsonar.pullrequest.key="${CI_COMMIT_PULL_REQUEST}" -Dsonar.pullrequest.branch="${CI_COMMIT_SOURCE_BRANCH}" -Dsonar.pullrequest.base="${CI_COMMIT_TARGET_BRANCH}")
|
sonarOpts=(-Dsonar.pullrequest.key="${CI_COMMIT_PULL_REQUEST}" -Dsonar.pullrequest.branch="${CI_COMMIT_SOURCE_BRANCH}" -Dsonar.pullrequest.base="${CI_COMMIT_TARGET_BRANCH}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sonar-scanner -Dsonar.working.directory=/tmp/.scannerwork -Dsonar.qualitygate.wait=true "${sonarOpts[@]}" || true
|
sonar-scanner -Dsonar.working.directory=/tmp/.scannerwork -Dsonar.qualitygate.wait=true "${sonarOpts[@]}" || true
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
projectKey=$(grep 'projectKey=' /tmp/.scannerwork/report-task.txt | cut -d'=' -f2)
|
|
||||||
taskId=$(grep 'ceTaskId=' /tmp/.scannerwork/report-task.txt | cut -d'=' -f2)
|
|
||||||
analysisId=$(wget -q -O- --header "Authorization: Bearer ${SONAR_TOKEN}" "${SONAR_HOST_URL}/api/ce/task?id=${taskId}" | jq -r '.task.analysisId')
|
|
||||||
report=$(wget -q -O- --header "Authorization: Bearer ${SONAR_TOKEN}" "${SONAR_HOST_URL}/api/qualitygates/project_status?analysisId=${analysisId}")
|
|
||||||
|
|
||||||
status=$(echo "${report}" | jq -r '.projectStatus.status')
|
|
||||||
conditions=$(echo "${report}" | jq -r '.projectStatus.conditions[] | "\n* " + .metricKey + "\n - Status: " + .status + "\n - Value: " + .actualValue')
|
|
||||||
[[ -n "${CI_COMMIT_PULL_REQUEST}" ]] && link="pullRequest=${CI_COMMIT_PULL_REQUEST}" || link="branchName=${CI_COMMIT_BRANCH}"
|
|
||||||
|
|
||||||
comment="## Quality Gate: **${status}**
|
|
||||||
${conditions}
|
|
||||||
|
|
||||||
[See analysis details](${SONAR_HOST_URL}/dashboard?id=${projectKey}&${link})"
|
|
||||||
|
|
||||||
echo "$comment"
|
|
||||||
|
|
||||||
if [[ -n "${CI_COMMIT_PULL_REQUEST}" ]]; then
|
|
||||||
comment=$(echo "${comment}" | jq -R -s '.')
|
|
||||||
wget -q -O /dev/null --post-data "{\"body\": $comment}" --header 'Content-Type: application/json' --header "Authorization: Bearer ${GITEA_TOKEN}" \
|
|
||||||
"${CI_FORGE_URL}/api/v1/repos/${CI_REPO}/issues/${CI_COMMIT_PULL_REQUEST}/comments"
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue