Can we add tags to issues while creating them?

I am using org.sonar.api.batch.sensor.issue.NewIssue class to create/raise a new Issue in my custom plugin.
I need to add tags to the Issues while creating the new Issue. And I know that it’s possible since I can do it via WebAPI and UI.

I am using Sonarqube 7.7 Community and sonar-plugin-api 7.7

Is it even possible via the sonar-plugin-api?

Hi,

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

7.7 → 7.9 → 8.9.10 → 9.9.2 → 10.2.1 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

Regarding your question, on creation issues inherit their tags from the underlying rules. Adding additional tags is an edit, whether through the API or the UI.

 
HTH,
Ann

So we can’t add tag while we create an issue via the this class ( org.sonar.api.batch.sensor.issue.NewIssue)?
Is there any other way?

Can we assign it to some user when we are raising the issue?

Hi,

I’m not familiar with the details of that API. I was speaking of the Web API. From the server side it’s quit possible you could. You should explore what’s available in the API.

 
Ann

I have explorred the API and was unable to find a way. Can you flag it someone who is well veresd with the API (org.sonar.api).

Hi,

I cannot. Not while you’re on an EOL version. And especially not one as old as 7.7.

 
Ann

If it’s is possible to achieve this in newer versions, I will upgrade my sonarqube :slight_smile:
But first can u confirm that it’s doable.

We are using SonarQube 9.9. Being able to set tags via NewIssue from within our plugin (Sensor implementation) would also be helpful for us.

As far as I understand it’s only possible via the UI or the REST API (POST api/issues/set_tags) at the moment. The REST API does not appear to be feasible because the issue does not exist until the analysis has been run in SonarQube. Or am I missing something?

Hi @LarsSt,

You are not. If you want to set tags at issue creation, then set them on your rules and the issues will naturally inherit.

 
HTH,
Ann

Thanks for your quick response. I’m talking about tags on individual issues, not on rules.

The same as you can do on the UI here:

Hi,

Yeah, that’s just not possible. Set them on the rules to be inherited by all issues, or add them after.

 
Ann

Ok, thanks for confirming. Could this be placed as a feature request somehow? Let me know if you need a customer / server ID to give it more legitimacy.

And while we’re at it, these issue tags would also be great to have access to in org.sonar.api.ce.measure.Issue while calculating measures.

Hi,

I’ll flag this for product manager attention, but I wouldn’t hold my breath if I were you.

 
Ann

1 Like