Commit 8dead872 authored by Nils Mittler's avatar Nils Mittler 🕵🏼
Browse files

enable local sonarqube analysis

parent 31436485
......@@ -61,3 +61,7 @@ rabbitmq.env
init-mongo.js
mongodb
rabbitmq
# Analysis Folder
.lcov_output
.scannerwork
FROM sonarsource/sonar-scanner-cli:4
RUN apk add --no-cache curl
RUN apk add --no-cache chromium
ENV CHROME_BIN=/usr/bin/chromium-browser
version: '3.7'
services:
analysis:
image: localhost/sonarscanner-cli
build:
context: ..
dockerfile: analysis/Dockerfile
working_dir: /click
entrypoint: /click/analysis/entrypoint.sh
depends_on:
- sonarqube
networks:
- sonar
volumes:
- ..:/click
sonarqube:
image: sonarqube:7.9.1-community
environment:
- SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true
ports:
- '9000:9000'
networks:
- sonar
volumes:
- sonar_data:/opt/sonarqube/data
networks:
sonar:
volumes:
sonar_data:
#!/bin/bash
if [[ $(curl -s -o /dev/null -w "%{http_code}" -u admin:admin -X POST http://sonarqube:9000/api/qualitygates/list) != 200 ]]; then
echo "Sonarqube has not finished startup yet."
echo "check http://localhost:9000 for progress."
echo "Please try again later..."
exit 0
fi
if [[ $(curl -s -o /dev/null -w "%{http_code}" -u admin:admin -X POST -F 'id=2' http://sonarqube:9000/api/qualitygates/show) == 404 ]]; then
# quality gate does not yet exist
echo "Quality Gate not yet existing. Going to create..."
# create the gate
curl -s -o /dev/null -w " - Creating gate: %{http_code}\n" \
-u admin:admin -X POST \
-F 'name=cards' \
http://sonarqube:9000/api/qualitygates/create
# create the conditions
curl -s -o /dev/null -w " - Add coverage condition: %{http_code}\n" \
-u admin:admin -X POST \
-F 'error=80' -F 'gateId=2' -F 'metric=coverage' -F 'op=LT' \
http://sonarqube:9000/api/qualitygates/create_condition
curl -s -o /dev/null -w " - Add duplicated lines condition: %{http_code}\n" \
-u admin:admin -X POST \
-F 'error=3' -F 'gateId=2' -F 'metric=duplicated_lines_density' -F 'op=GT' \
http://sonarqube:9000/api/qualitygates/create_condition
curl -s -o /dev/null -w " - Add sqale rating condition: %{http_code}\n" \
-u admin:admin -X POST \
-F 'error=1' -F 'gateId=2' -F 'metric=sqale_rating' -F 'op=GT' \
http://sonarqube:9000/api/qualitygates/create_condition
curl -s -o /dev/null -w " - Add reliability rating condition: %{http_code}\n" \
-u admin:admin -X POST \
-F 'error=1' -F 'gateId=2' -F 'metric=reliability_rating' -F 'op=GT' \
http://sonarqube:9000/api/qualitygates/create_condition
curl -s -o /dev/null -w " - Add security rating condition: %{http_code}\n" \
-u admin:admin -X POST \
-F 'error=1' -F 'gateId=2' -F 'metric=security_rating' -F 'op=GT' \
http://sonarqube:9000/api/qualitygates/create_condition
# set newly created gate as default
curl -s -o /dev/null -w " - Setting newly created gate as default: %{http_code}\n" \
-u admin:admin -X POST \
-F 'id=2' \
http://sonarqube:9000/api/qualitygates/set_as_default
echo "done."
fi
npm i
export NODE_ENV='test'
node_modules/nyc/bin/nyc.js --reporter=text --reporter=lcov --report-dir=.lcov_output node_modules/mocha/bin/mocha
sonar-scanner
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment