To init the server
npm run sonar:init-server
To run the analysisnpm run sonar:analysis
To inspect the analysis, go to http://localhost:9000. The credentials are admin
and password 12345
change_password () { | |
response=$(curl \ | |
--write-out '%{http_code}' \ | |
--silent \ | |
--output /dev/null \ | |
-u admin:admin \ | |
-X POST \ | |
"http://host.docker.internal:9000/api/users/change_password?login=admin&previousPassword=admin&password=$SONAR_PASSWORD") | |
if [ "$response" == "204" ] | |
then | |
echo "Password changed successfully to $SONAR_PASSWORD" | |
true | |
elif [ "$response" == "401" ] | |
then | |
echo "Password already changed. Is $SONAR_PASSWORD" | |
true | |
else | |
false | |
fi | |
} | |
try_to_change_pass () { | |
max_retry=20 | |
counter=0 | |
until change_password | |
do | |
sleep 4 | |
[[ $counter -eq $max_retry ]] && echo "Failed trying to reach SonarQube server" && exit 1 | |
echo -e "\nSonarQube server not accesible. Try #$counter" | |
let "counter+=1" | |
done | |
} | |
try_to_change_pass |
version: '3' | |
services: | |
sonar_server: | |
image: sonarqube | |
ports: | |
- '9000:9000' | |
sonar_cli: | |
image: sonarsource/sonar-scanner-cli | |
profiles: ['cli'] | |
volumes: | |
- ./:/usr/src | |
env_file: | |
- env_vars | |
command: /bin/bash -c 'sonar-scanner -Dsonar.host.url=$$SONAR_HOST_URL -Dsonar.login=admin -Dsonar.password=$$SONAR_PASSWORD' | |
change_sonar_server_password: | |
image: curlimages/curl | |
volumes: | |
- ./change_password.sh:/home/curl_user/change_password.sh | |
env_file: | |
- env_vars | |
command: ash -c "/home/curl_user/change_password.sh" |
SONAR_HOST_URL=http://host.docker.internal:9000 | |
SONAR_PASSWORD=12345 |
To init the server
npm run sonar:init-server
To run the analysisnpm run sonar:analysis
To inspect the analysis, go to http://localhost:9000. The credentials are admin
and password 12345
An example project that is currently using this configuration -> https://github.com/bikecoders/ngx-deploy-npm/blob/master/docker-compose.yml