From 114b4376ead68e1c372dc36772d60f46ea964ce7 Mon Sep 17 00:00:00 2001 From: nyyu Date: Sun, 21 Jul 2024 14:14:09 +0200 Subject: [PATCH] chore: remove comment --- sonar.sh | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/sonar.sh b/sonar.sh index 2b8b869..24fc7ef 100755 --- a/sonar.sh +++ b/sonar.sh @@ -1,40 +1,9 @@ #!/bin/bash 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}") 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}") fi 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