Extracting last analysis on a specific branch

  • which versions are you using - Enterprise Edition Version 8.9.10 (build 61524)
  • what are you trying to achieve - List the last analysis on a specific branch
  • what have you tried so far to achieve this - Using APIs

Hello there,

I’m actually trying to answer a security request asking me to scan all the projects once a year.
We’ve built a Jenkins job to relaunch a deployment on a specific branch for each projects, but, I thrive to get a list with the LastScanAnalysis of those projects on that specific branch.

Going through the web APIs, I do get a list but it’s based on the master branch.

I’m open for any solution, even a DB request :slight_smile:

Thanks alot for your help,
Michel

Hi Michel,

Have you tried this via the UI? The APIs are going to default to the main branch unless you’ve specified which branch you want to pull data for. The best way to master the API is to perform the desired action via the UI and eavesdrop to see which calls the UI made to accomplish the action.

You may also find this guide helpful.

 
HTH,
Ann

Hello Ann,

I’m trying to get the analysisdate of all my projects on the “release-PROD” branch

I get what I want using:

/api/components/show?id=xx.xxx.angular.fitness%3Aang-fitness&component=xx.xxx.angular.fitness%3Aang-fitness&branch=release-PROD

Result is:

{“component”:{“key”:“xx.xxx.angular.fitness:ang-fitness”,“name”:“ANG Fitness (FIT-0002)”,“qualifier”:“TRK”,“analysisDate”:“2023-01-16T14:00:29+0100”,“tags”:,“visibility”:“private”,“leakPeriodDate”:“2023-01-13T08:29:09+0100”,“branch”:“release-PROD”,“version”:“2.1.18”,“needIssueSync”:false},“ancestors”:}

…but I have to specify the project.

If I use:

/api/components/search?qualifiers=TRK&branch=release-PROD

I get a nice list with all my projects but not the analysisDate & branch :face_with_head_bandage:

All my Sonar dreams will be fullfilled if I can get that with the full list of my projects with the last analysisDate on my release-PROD branch :slight_smile:

As a sidenote, I’m not comfortable with the API syntax (not my cup of tea) but I try to search as far as i can.

If you can help me, it will be greatly appreciated. I’m still searching :slight_smile:

Thanks alot,
Michel

Hi Michel,

Looks like you’ll need to iterate through your projects making the call you’ve already used to successfully get the data you’re after.

 
Ann

Hello Ann,

Yes, that was also my conclusion after different attempts.
I’ll fetch the data and work it out.

Thanks anyway for your answers :slight_smile:

Have a nice day,
Michel

1 Like