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 52 forks source link

Why cant specify projectKey and projectName? #24

Open josevavia opened 3 years ago

josevavia commented 3 years ago

According to docs:

projectKey: DRONE_REPO
projectName: DRONE_REPO
You could also add a file named sonar-project.properties at the root of your project to specify parameters.

why not be able to set projectKey and projectName using settings in drone pipeline?

I have a project with a lot of git branches, and I want to send to sonarqube each branch as a different project. With the actual approach, I need to set different settings in sonar-project.properties for each branch to get that.

It would be great if I can set key and project name in the plugin settings, as I have different steps in drone.yml for each branch.

I dont know if there is any technical reason for this

josevavia commented 3 years ago

As a solution, I can get it working using following setup:

drone.yml:

  - name: sonarqube
    image: aosapps/drone-sonar-plugin
    settings:
      sonar_host:
        from_secret: sonar_host
      sonar_token:
        from_secret: sonar_token
      usingProperties: true

sonar-project.properties (in branch-1):

sonar.projectName=Branch 1
sonar.projectKey=com.domain.branch-1

sonar-project.properties (in branch-2):

sonar.projectName=Branch 2
sonar.projectKey=com.domain.branch-2

Anyway, I think it would be great that we can be able to set projectKey and projectName as settings in drone pipeline, something like this:

  - name: sonarqube
    image: aosapps/drone-sonar-plugin
    when:
      branch:
        branch-name-1
    settings:
      sonar_host:
        from_secret: sonar_host
      sonar_token:
        from_secret: sonar_token
      projectKey: com.domain-branch-1
      projectName: Branch 1

  - name: sonarqube
    image: aosapps/drone-sonar-plugin
    when:
      branch:
        branch-name-2
    settings:
      sonar_host:
        from_secret: sonar_host
      sonar_token:
        from_secret: sonar_token
      projectKey: com.domain-branch-2
      projectName: Branch 2

This way, the configuration is made in the specific step for each branch, and sonar-project.properties is not needed.

Hpareek07 commented 3 years ago

Hi can you please help I am also facing the same issue. Not able to specify projectKey and Name parameters. I tried adding it to sonar-project.properties but it is not picking up the values. I am using drone v 0.8 , so usingProperties flag does not work for me.

josevavia commented 3 years ago

Hi @Hpareek07 I cant help you. As you can see in my example, I am using usingProperties flag to get it work

It seems that this feature has no interest in the community. If I have some spare time I will try to fork the plugin to do it myself, but cant promise anything

Et7f3 commented 1 year ago

linked to #28