Add comments at the project level

Is there any place to add comments to an entire project (not an individual issue)? We would like to add some metadata (a few hundred characters at most) to each project, something that could be retrieved, such as with api/projects/search.

I could do some hideous kludge, such as adding a comment to a known issue and giving it a special custom tag so I can find it. But I’m hoping for a cleaner solution.

Hi,

Actually, yes. sonar.projectDescription (which is actually vestigial at this point, but we’re really bad about removing unused stuff) will allow you to do what you want. Unfortunately, I suspect it will only be shown on the ‘Project Information’ page.

 
HTH,
Ann

I see the Description field under Project Information, but I don’t see any kind of fill-in box. All I see is some place to search for tags, and it says “No tags”. Is this something where I need to create a tag, and then associate a value with it? Or is this a feature only for the pay-versions?

Also, is it possible to get at this Description field through the web_api?

Hi,

It’s an analysis parameter. That’s the only way to set that value.

 
HTH,
Ann

So you mean something like add a sonar.ProjectDescription field to the POM that Maven reads? If that’s the only way to add that, it means I can’t change it without doing another build. :frowning:

But your mentioning project analyses got me thinking, and I think I found something that might work for us though. We can add an event to one of the analyses for a given project, using either the web portal or the web_api, and edit and read it through the same. I was able to store an event with up to 400 characters (401 failed though – but 400 is way more than enough for what I want). Then I can search the project analyses, filtering with the event category. Unfortunately, I can’t create my own custom event category; I basically need to use OTHER. So I should add some sort of prefix to the event name to distinguish from other events of the same category.

Yes, it’s a kludge… :slight_smile:

Hi,

Yes. Or set it on the analysis command line: -Dsonar.projectDescription="This is Ann's long-winded description that might not really be appropriate for command line usage but this is where I'm putting it because I don't want to edit the POM"

In a fine and storied tradition… :joy:

 
Ann

1 Like

Well we use Jenkins so manually setting it in the command line isn’t an option – though I guess we could configure Jenkins to do so automatically. But once that happens, is there any way to read this through the web_api? Ultimately we need for scripts to be able to read and use this data (not necessarily change it).

Hi,

Here you go:

https://next.sonarqube.com/sonarqube/api/measures/component?component=sonarqube&metricKeys=ncloc%2Cprojects

Yields

{
  "component": {
    "key": "sonarqube",
    "name": "SonarQube",
    "description": "Open source platform for continuous inspection of code quality",
    "qualifier": "TRK",
    "measures": [
      {
        "metric": "ncloc",
        "value": "237887"
      }
    ]
  }
}

As seen here.

 
HTH,
Ann

I was able to use that endpoint to get things like ncloc, but I’m not finding the sonar.projectDescription field, or any of the fields discussed here ( Analysis parameters | SonarQube Server 9.8 | Sonar Documentation ) which I found from a search engine. And in that page I saw no reference to ncloc, so I think we’re talking about two different things. I’m looking for an endpoint that will return the things listed on that webpage.

I did a Google search and got an AI-generated answer, which was of course completely wrong.

Hi,

Shocked. I’m shocked, I tell you.

Just… why? Are you running 9.8?

Did you try the link I posted? This one?

Because really early in the response is the field Description.

I got that URL, BTW by eavesdropping on the UI to see which calls the it made.

You may also find this guide helpful.

 
Ann