aosapps / drone-sonar-plugin

The plugin of Drone CI to integrate with SonarQube (previously called Sonar), which is an open source code quality management platform.
MIT License
30 stars 51 forks source link

Plugin does not seem to be using the sonar-project.properties file #14

Closed Bhargav-Rao closed 4 years ago

Bhargav-Rao commented 4 years ago

Hi, I'd like to thank you for creating this awesome plugin. I was playing around with it and found it very intuitive to use. I'm facing a small problem, and would like to make sure that it isn't a bug. The documentation mentions:

The projectKey and projectName of SonarQube project are filled using the full repository name. You could also add a file named sonar-project.properties at the root of your project to specify parameters.

I specified a sonar-project.properties file, but the plugin still seems to use the repository name, instead of the one specified as the project key. The sonar-project.properties file is:

sonar.projectKey=testing-drone-sonar
sonar.projectName=testing-drone-sonar
sonar.sources=src
sonar.language=py
sonar.python.coverage.reportPath=coverage.xml
sonar.python.xunit.reportPath=pytest.xml

The .drone.yml file is:

---
kind: pipeline
name: test-drone

type: docker
steps:
- name: deploy
  image: python:3.8
  commands:
    - pip install pipenv
    - pipenv install --dev
    - pipenv run python -m pytest --cov-report=html:htmlcov --cov=src --junitxml=pytest.xml
    - pipenv run python -m coverage xml -i
- name: code-analysis
  image: aosapps/drone-sonar-plugin
  settings:
    sonar_host:
      from_secret: sonar_host
    sonar_token:
      from_secret: sonar_token

And I have my .drone.yml and the sonar-project.properties file at my root.

Can you take a look at this and let me know if it is a bug, or if I need to change the configurations in some way? Thanks for your help.

roganw commented 4 years ago

This plugin does not read the sonar-project.properties file, please refer the Parameter Reference. The repository name is regarded as the project key and project name.

bistory commented 4 years ago

The documentation stats this : "You could also add a file named sonar-project.properties at the root of your project to specify parameters." So it is intended to read that file, no ?...

Bhargav-Rao commented 4 years ago

Yep, it looks like the documentation needs to be updated to be more clear.

roganw commented 4 years ago

@Bhargav-Rao You could refer the newest code and doc, which supports the 'sonar-project.properties' configuration, do a test using image aosapps/drone-sonar-plugin:latest.

bistory commented 4 years ago

It works, thank you @roganw ! ;-)