DEV Community

Mpho Mphego
Mpho Mphego

Posted on

How I configured SonarQube for Python code analysis with Jenkins and Docker

Liquid syntax error: Unknown tag 'endraw'

Top comments (4)

Collapse
 
perchrh profile image
Per Christian Henden

Practical issue with a missing parameter in the docker run command:
It should have been
$ docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube
The last parameter is the missing one, the image name.
Doesn't work at all with docker 19.0.3 without the final parameter, for me.

Collapse
 
anortef profile image
Adrián Norte

Awesome! As a DevOps, I'm so glad to see developers caring about the objective quality of their code.

Want to try this?

With the DSL hosted on a git repo and your current setup adding a tweaked Jenkins image, you can have a full stateless CI environment.

Collapse
 
nskmda profile image
nskmda • Edited

Can you please confirm some extra configuration (like Python-related plugin) needs to be done on the Sonar server side?

I got all the configs in my local Gradle project and I don't get any errors from the Gradle sonar plugin (which is configured and most likely does find the coverage report generated by Python Coverage) but on the server side I don't see anything.

A hint: my company is primarily a Java shop and most likely the new project in Sonar was created with some default settings.

I'm just trying to confirm some extra Python-specific configuration might need to be done on the Sonar server before I turn to the Sonar admin for help.

Collapse
 
sauravbhagat profile image
saurav kumar bhagat

Hi, in my project, I want to exclude a file from sonarqube scan, and I am using this property for that,
sonarDetails:
sourcesPath: "src"
additionalProperties: "-Dsonar.coverage.exclusions=**/src/main.py"

But this file is not getting excluded and coverage is not exceeding 50%.
Can you help with this?
Thanks