Adding tags to a project via analysis properties?

Hi,

Is it possible to add tags to a project within the sonar-projects.properties file?

There’s no mention of it in the documentation (from what i’ve seen) - it would not be good if we (the administrators) have to do this manually on the project page.

Thanks

7 Likes

Hi,

This is not possible.

Would you explain why, please? Project tags are not meant to be ephemeral; changing from analysis to analysis. They’re meant to categorize the project as a whole.

 
Ann

We would use the feature to tag the project (e.g. technology, or architectural context).
We would use the tags within Sonarqube then to define portfolios with the help of the tags, without the need to manually maintain this.

1 Like

Hi @thjenny,

Your use case is perfectly supported - via the UI.

 
:slight_smile:
Ann

Hi Ann,
I know that I can do this via the UI, but I’d like to automate this, as I said: “without the need to manually maintain this”.
So no, not “perfectly” supported. If we can automate this, we could define these project attributes or tags in the source itself in one place, and the build process could use it in multiple contexts, for Sonar, but also e.g. to link to the architectural documentation, …

4 Likes

Hi,

The UI uses web services (api/project_tags/set). Your automation could too.

 
Ann

1 Like

I don’t really understand this answer.
sonar.projectKey is not ‘ephemeral’
sonar.projectName is not really either nor sonar.projectDescription

Why couldn’t we add project metadata directly in the properties ?
Projects are mostly created automatically from CI, adding the tags in the properties file makes the whole process a lot easier.

9 Likes

Hi Ann!

I hope all is well with you!
I’m a +1 for this feature request. We have a documented template for the sonar-project.properties file for a given domain context. When a new project is created, this template is used and only sonar.projectKey and projectName need to be set. But we need to manually tag the new project in the UI (the issue is that one might forget). Having the tags already in the sonar-project.properties template would be an easier and more reliable solution.

BTW, this has been asked on SO as well: https://stackoverflow.com/questions/47146216/sonarqube-project-tagging-via-properties.

Paulo

5 Likes

I would like to add my support for this feature request. We are a large organization with many (1000+) projects. We use project tags to differentiate components belonging to different teams or departments. Having a way for teams to add in project level metadata without having to log into a UI would be a tremendous help for us. Unfortunately, the ability to add tags is restricted to Administrators (ASFAIK) and this is not something that we’re willing to distribute to all developers.

4 Likes

For the record @jorcutt.ebsco, Project Administrators can add tags, and IMO someone in each project should be a project admin. Otherwise, yeah. You really are biting off a lot at the global admin level.

 
HTH,
Ann

1 Like

Hi all!

Just to let you know. I have found a plugin (Project Tag) that pretends to add this feature into SonarQube.

Check it out:

It seems quite simple but maybe it is what you are looking for.

Best regards.

1 Like

This feature would be most helpful. For instance, in sonar-scanner.properties:

sonar.tags=frontend,public

6 Likes

+1 for this feature as well exactly as Jonathan suggested.

We have to create a properties file for each new project. The projects are split between teams. It makes sense to add the team name as a tag when we create the property file. The project is then immediately tagged when created for the first time (this would be done when the project first builds in CI).

Having to have some ‘admin’ go in and then tag the project via the UI seems a little backwards. I would assume most devs in SonarSource would agree with this point of view. You should ask them.

1 Like

+1
configuration as code is a norm thesedays.

2 Likes

I Used API call and it worked. It also creates a new one if it doesn’t exist.

httpRequest(httpMode: ‘POST’, url: ("{env.sonarServerUrl}/api/project_tags/set?project={env.groupid}:{env.artifactid}&tags={env.tag}"), authentication: ‘<>’)

Where you can define your env variables on your own or you can use it like env.groupid. So projects related to a groupid will be easy to track

1 Like

FYI all, I’ve moved this to the ‘Suggest new features’ category.

 
Ann

5 Likes

I also would like to see this feature.
Could have the portfolios based on a regex of the project key, but that is quite limited.
Would be easiest to just have a sonar.project.tags property.

There will be an issue with manually added tags vs property added, as which one will take precedence?
Simplest solution is to remove capability to manually tag projects. The projectKey cannot be changed manually, so why should the tags be changed manually?

Hi! One more +1 to have this feature in terms like @Johnathan_Elmore suggested. It would be very helpful to set in via CI as well with other project attributes avoiding UI clicks which are significantly increase the time to maintenance thousands of SonarQube projects.

API workaround is nice, but it’s much harder to implement this in CI because it requires extra scripting. Just setting sonar.tags would be great!

1 Like

+1. This is definitely needed feature. 4 years since this post and the feature is still lacking.

Why can’t we just have tags as part of the sonar.properties file?

@Abhijeet_Vaikar

  • Can you describe why you need to tag projects from the sonar.properties and why this is not possible to rely on the API or UI to achieve this task?
  • Is it at project creation that you need that or even for the subsequent analyses?

Thanks
Alex

1 Like