test/ci: fix sonarqube run on main

Minor oversight from previous commit. Specify clone depth in
.gitlab-ci.yml file instead.
This commit is contained in:
Jakub Rusz 2022-01-25 15:46:49 +01:00 committed by Alexander Todorov
parent 8bc4bff80c
commit b38524b7ee
2 changed files with 5 additions and 15 deletions

View file

@ -80,11 +80,10 @@ SonarQube:
extends: .terraform
script:
- schutzbot/sonarqube.sh
parallel:
matrix:
- RUNNER:
- aws/centos-stream-8-x86_64
INTERNAL_NETWORK: "true"
variables:
RUNNER: aws/centos-stream-8-x86_64
INTERNAL_NETWORK: "true"
GIT_DEPTH: 0
finish:
stage: finish

View file

@ -9,16 +9,8 @@ sudo dnf install -y unzip
curl "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_CLI_VERSION-linux.zip" -o sonar-scanner-cli.zip
unzip -q sonar-scanner-cli.zip
SONAR_SCANNER_CMD="$(pwd)/sonar-scanner-$SONAR_SCANNER_CLI_VERSION-linux/bin/sonar-scanner"
SONAR_SCANNER_CMD="sonar-scanner-$SONAR_SCANNER_CLI_VERSION-linux/bin/sonar-scanner"
# SonarQube complains about shallow git clone so do a full checkout in tempdir
FOLDER="$(mktemp -d)"
pushd "$FOLDER"
git clone http://github.com/osbuild/osbuild
cd osbuild
PR_NUMBER=${CI_COMMIT_BRANCH/*-/}
git fetch origin pull/"$PR_NUMBER"/head:sonarscan
git checkout sonarscan
$SONAR_SCANNER_CMD -Dsonar.projectKey=osbuild:osbuild \
-Dsonar.sources=. \
-Dsonar.host.url=https://sonarqube.corp.redhat.com \
@ -26,7 +18,6 @@ $SONAR_SCANNER_CMD -Dsonar.projectKey=osbuild:osbuild \
-Dsonar.pullrequest.branch="$CI_COMMIT_BRANCH" \
-Dsonar.pullrequest.key="$CI_COMMIT_SHA" \
-Dsonar.pullrequest.base="main"
popd
SONARQUBE_URL="https://sonarqube.corp.redhat.com/dashboard?id=osbuild%3Aosbuild&pullRequest=$CI_COMMIT_SHA"
# Report back to GitHub