Setup sonarscanner

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2022-02-17 13:31:19 -05:00
parent 3ce1a3f450
commit 2d762f40ab
3 changed files with 31 additions and 1 deletions

View file

@ -37,3 +37,33 @@ echo "+++ bundle exec rake ${RAKE_TASK:-}"
# su normal -c "bundle exec rake ${RAKE_TASK:-}" # su normal -c "bundle exec rake ${RAKE_TASK:-}"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
bundle exec rake ${RAKE_TASK:-} bundle exec rake ${RAKE_TASK:-}
RAKE_EXIT=$?
# If coverage is enabled, then we need to pick up the coverage/coverage.json file
if [ -n "${CI_ENABLE_COVERAGE:-}" ]; then
echo "--- installing sonarscanner"
export SONAR_SCANNER_VERSION=4.6.2.2472
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
echo "--- installing vault"
export VAULT_VERSION=1.9.3
export VAULT_HOME=$HOME/vault
curl --create-dirs -sSLo $VAULT_HOME/vault.zip https://releases.hashicorp.com/vault/$VAULT_VERSION/vault_${VAULT_VERSION}_linux_amd64.zip
unzip -o $VAULT_HOME/vault.zip -d $VAULT_HOME
echo "--- fetching Sonar token from vault"
export SONAR_TOKEN=$($VAULT_HOME/vault kv get -field token secret/inspec/sonar)
echo "--- running sonarscanner"
sonar-scanner \
-Dsonar.organization=inspec \
-Dsonar.projectKey=inspec_inspec \
-Dsonar.sources=. \
-Dsonar.host.url=https://sonarcloud.io
fi
exit $RAKE_EXIT

View file

@ -25,7 +25,6 @@ pipelines:
- ADHOC: true - ADHOC: true
- verify: - verify:
description: Pull Request validation tests description: Pull Request validation tests
public: true
env: env:
- LANG: "C.UTF-8" - LANG: "C.UTF-8"
- SLOW: 1 - SLOW: 1

View file

@ -29,6 +29,7 @@ steps:
command: command:
- /workdir/.expeditor/buildkite/verify.sh - /workdir/.expeditor/buildkite/verify.sh
expeditor: expeditor:
secrets: true
executor: executor:
docker: docker:
image: ruby:3.0 image: ruby:3.0