Tag projects through sonar-scanner

It’s possible to add tags to projects through the web interface, but in a CI environment, you would want to set the tags for a project through the sonar-scanner.

The parameter on the scanner should accept a comma separated string where each item would represent a tag;
If a tag exist on the project, but not in the list supplied by the scanner, it should be removed from the project. This rule should toggled on/off through the global settings in SonarQube;

Ideally, it would be done using /d:sonar.project.tags="tag1, tag2, tagN" or /d:sonar.tags="tag1, tag2, tagN"

1 Like

Hi,

+1
this would be useful for CI/CD builds.
The documentation Project settings has only:

Project tags allow you to categorize and group projects for easier selection on the Projects page. Project tags can be administered from the project home page.

In the meantime you may use the web api api/project_tags/set (available since SQ 6.4) straightly.

Gilbert

1 Like

Yes, until the sonar scanners itself has been updated, we will be using the api’s to post this straight after the scanning has completed

thanks for the suggestion !

We faced a similar issue and we did solved it using Project Tag Plugin

Works like charm!

1 Like

+1
We bought the Enterprise version and we also need this feature.

1 Like

curl -u “yourtoken” -d “project=projectname&tags=projecttags” -X POST “https://yoursonar/api/project_tags/set

1 Like

we can use this api in Community EDITION?

+1 it helps me too:

I’ve tried it, but does not work:
./gradlew clean test cloverGenerateReport sonarQube -Dsonar.projectName=xxx -Dsonar.project.tags=xxx

looks like it is not available using gradle

1 Like

+1 Waiting for this feature. Team please update is there is plan to release this.

The purpose of tag is to set on project level.
When you use sonar-scanner to set the tags it would become difficult when the number for branches and PR are huge, making it un reliable solution.

Project tags are not meant to be ephemeral; changing from analysis to analysis. They’re meant to categorize the project as a whole