Adding custom info without admin rights

Hello,

I’ve a requirement in which I want my development teams to pass an additional info about project while scanning. Preferably within sonar-project.properties.

This additional info is a meta information about the project, which I want to later fetch via sonarqube’s REST API.

I’ve gone thru documentations and Q&A and have came across below possible solutions, but some info missing:

  1. sonar.analysis.[yourKey] - According to documentation, I can pass meta info using this analysis-parameter. But how can I fetch this info back via REST API. Suppose in my project properties I pass sonar.analysis.mymeta=XYZ, can I get it’s value in REST call?

  2. Custom Measures - This allows me to set the meta info, but not via properties file & also requires ‘Administer System’ permission or ‘Administer’ permission on the project. Is there a workaround for this?

  3. Project Tags - I can set my meta info in TAG, but here also not via properties file & also requires ‘Administer System’ permission on the project. Is there a workaround for this?

Please assist. If there any another approach, please suggest that as well.

Regards
Rahul Saini

Hi Rahul,

This is probably the best route. You’ll find the data in your “Scanner Context” which you can see in the UI on the Background tasks page and via the API in the api/ce/task results (note that context is delivered in this response in a big lump of text you’ll have to parse).

There is no workaround. Additionally, values have to be set before analysis (I guess that could happen via web service calls) and values are only preliminary until analysis actually takes place.

The potential drawback with this is that there’s no history on tags. Add a value and it’s as if it was always there. Remove it and it’s gone like it never happened.

 
HTH,
Ann

Thanks Ann, as always.

1 Like

Hi
sonar.analysis.[yourKey]
how can I get this data in ‘JavaFileScannerContext’ ,because I scan java file

Hi @Zhou,

Welcome to the community!

I have nothing to add to what I posted above.

 
Ann