Skip to content

Instantly share code, notes, and snippets.

@sickcodes
Created July 24, 2021 21:49
Show Gist options
  • Save sickcodes/09918a4baa4169a9bf77a22071893d6a to your computer and use it in GitHub Desktop.
Save sickcodes/09918a4baa4169a9bf77a22071893d6a to your computer and use it in GitHub Desktop.
Start local passwordless SonarScanner Docker container localhost
#!/bin/bash
# Author: sickcodes
# Contact: https://twitter.com/sickcodes
# Copyright: sickcodes (C) 2021
# License: GPLv3+
# admin
# mypassword
export PASSWORD=mypassword
function sonar_change_password () {
curl -u admin:admin --location --request POST \
"http://localhost:9000/api/users/change_password?login=admin&password=${1}&password_confirmation=${1}&previousPassword=admin"
}
docker kill sonarqube
sleep 1
docker rm sonarqube 2>/dev/null
docker pull sonarqube
docker run -d --name sonarqube \
-e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true \
-p 9000:9000 \
sonarqube:latest
sleep 10
until ! [[ "$(sonar_change_password "${PASSWORD}" | grep errors)" ]]; do
sleep 5
done
touch ~/.sonarcube_token
curl -u admin:"${PASSWORD}" --request POST "http://localhost:9000/api/user_tokens/generate?name=${SEMI[0]}" > ~/.sonarcube_token
curl -u admin:"${PASSWORD}" --location --request POST "http://localhost:9000/api/settings/set?key=sonar.allowPermissionManagementForProjectAdmins&value=false"
curl -u admin:"${PASSWORD}" --location --request POST "http://localhost:9000/api/settings/set?key=sonar.forceAuthentication&value=false"
# cd project
# /opt/sonar-scanner/bin/sonar-scanner \
# -Dsonar.projectKey="$(basename "${PWD}")" \
# -Dsonar.sources="${PWD}" \
# -Dsonar.host.url=http://localhost:9000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment