ci-scripts/sonar.sh

15 lines
574 B
Bash
Raw Normal View History

2024-06-24 16:54:05 +02:00
#!/bin/bash
set -e
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
2024-12-15 11:55:42 +01:00
if [[ -f "package.json" ]]; then
version=$(awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json)
sonarOpts+=(-Dsonar.projectVersion="${version}")
fi
2024-06-24 16:54:05 +02:00
sonar-scanner -Dsonar.working.directory=/tmp/.scannerwork -Dsonar.qualitygate.wait=true "${sonarOpts[@]}" || true