feat: version gradle
This commit is contained in:
parent
edc51e461a
commit
ddcd971010
1 changed files with 19 additions and 3 deletions
22
sonar.sh
22
sonar.sh
|
@ -1,14 +1,30 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
function xargs() {
|
||||||
|
local cmd=$1
|
||||||
|
shift
|
||||||
|
for arg in "$@"; do
|
||||||
|
$cmd "$arg"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f xargs
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
if [[ -f "package.json" ]]; then
|
if [[ -f "package.json" ]]; then
|
||||||
version=$(awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json)
|
version=$(awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json)
|
||||||
sonarOpts+=(-Dsonar.projectVersion="${version}")
|
sonarOpts+=(-Dsonar.projectVersion="${version}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -d "gradle" ]]; then
|
||||||
|
version=$(./gradlew --gradle-user-home /tmp/.gradle --project-cache-dir /tmp/.cachegradle properties -PbuildDir=/tmp/.buildgradle -q | awk '/^version:/ {print $2}')
|
||||||
|
sonarOpts+=(-Dsonar.projectVersion="${version}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
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
|
||||||
|
|
Loading…
Add table
Reference in a new issue