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"


this would be useful for CI/CD builds.
The documentation https://docs.sonarqube.org/latest/project-administration/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.


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

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

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 Waiting for this feature. Team please update is there is plan to release this.