Disable default password change

Hey,

I’m using the SonarQube server docker image
docker run -p 9000:9000 sonarqube:latest
and I’m trying to automate the sonar scanner with a Python script. For this, I also use the docker image of the sonar-scanner-cli (Docker Hub).

First, I start the server with the given command above. Then, I start the scanner on a folder with the following command:
docker run --rm -e SONAR_HOST_URL="http://localhost:9000" -v "/my/folder:/usr/src" --network=host sonarsource/sonar-scanner-cli -D sonar.projectKey=scan_result -D sonar.forceAuthentication=false -D sonar.login=admin -D sonar.password=admin

The scan itself works, but when I try to access the report after it has finished, I have to change the default password first on the SonarQube server. This is a bit annoying in my case because I just want to automate things for research purposes. Is there a somewhat easy way for me to disable this feature of having to change the default password? Or is there perhaps an easier way to automate the sonar scanner than my current setup with docker?

I’d appreciate any kind of help!

Cemal

Hi, welcome to the community forum. SonarQube requests a password change only for the default credentials admin:admin. Use any other custom values, and you won’t be prompted anymore.

Just so you know, we use orchestrator to automate our ITs on SonarQube. If that can ease your tests, feel free to use it.

1 Like

in addition to the possibility that Pierre mentioned, you could also wrap a api call to /api/users/change_password in your python script and change the password before you start the scanner if you recreate the sq instance every time as well.

here is an example with curl:

curl -u admin:admin -X POST "http://localhost:9000/api/users/change_password?login=admin&previousPassword=admin&password=newAdminPassword"

hope that helps :slight_smile:

3 Likes

Thank you both! The API call works perfectly for my case :slightly_smiling_face:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.