Update .gitea/workflows/sonarscan.yml
Some checks failed
SonarQube Quality Gate / SonarQube Scan (push) Failing after 1m20s
Some checks failed
SonarQube Quality Gate / SonarQube Scan (push) Failing after 1m20s
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
name: SonarQube Analysis
|
||||
name: SonarQube Quality Gate
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ testing, main ]
|
||||
branches:
|
||||
- testing
|
||||
- main
|
||||
|
||||
pull_request:
|
||||
branches: [ testing, main ]
|
||||
branches:
|
||||
- testing
|
||||
- main
|
||||
|
||||
env:
|
||||
SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }}
|
||||
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
|
||||
|
||||
jobs:
|
||||
sonarqube:
|
||||
@@ -22,7 +30,7 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Run Scan
|
||||
- name: Run SonarQube Scan
|
||||
run: |
|
||||
REPO_NAME=${{ gitea.event.repository.name }}
|
||||
|
||||
@@ -30,7 +38,39 @@ jobs:
|
||||
-Dsonar.projectKey=$REPO_NAME \
|
||||
-Dsonar.projectName=$REPO_NAME \
|
||||
-Dsonar.sources=. \
|
||||
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} \
|
||||
-Dsonar.token=${{ secrets.SONARQUBE_TOKEN }} \
|
||||
-Dsonar.host.url=$SONAR_HOST_URL \
|
||||
-Dsonar.token=$SONAR_TOKEN \
|
||||
-Dsonar.exclusions=node_modules/**,dist/**,coverage/** \
|
||||
-Dsonar.qualitygate.wait=true
|
||||
-Dsonar.qualitygate.wait=true
|
||||
|
||||
- name: Install jq (required for parsing)
|
||||
if: gitea.event_name == 'pull_request'
|
||||
run: |
|
||||
apt-get update && apt-get install -y jq
|
||||
|
||||
- name: Get Quality Gate Result
|
||||
if: gitea.event_name == 'pull_request'
|
||||
run: |
|
||||
REPO_NAME=${{ gitea.event.repository.name }}
|
||||
|
||||
curl -s -u $SONAR_TOKEN: \
|
||||
"$SONAR_HOST_URL/api/qualitygates/project_status?projectKey=$REPO_NAME" \
|
||||
> result.json
|
||||
|
||||
STATUS=$(jq -r '.projectStatus.status' result.json)
|
||||
echo "STATUS=$STATUS" >> $GITHUB_ENV
|
||||
|
||||
- name: Comment on PR
|
||||
if: gitea.event_name == 'pull_request'
|
||||
run: |
|
||||
if [ "$STATUS" = "OK" ]; then
|
||||
MESSAGE=" SonarQube Quality Gate PASSED"
|
||||
else
|
||||
MESSAGE=" SonarQube Quality Gate FAILED"
|
||||
fi
|
||||
|
||||
curl -X POST \
|
||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"body\": \"$MESSAGE\"}" \
|
||||
${{ gitea.api_url }}/repos/${{ gitea.repository }}/issues/${{ gitea.event.pull_request.number }}/comments
|
||||
Reference in New Issue
Block a user