Get Long lived branches via API on a project

I’m trying to analyze branches via jenkins using multibranch plugin, but we are getting a problem that we are not capable to provide the correct target branch, (short-lived branches just provide differential information).

The idea then is to only analyze pull requests and long-lived branches, but for that, I need to get the REGEX of the long-lived branches applied of the project to know if I need to execute the analysis.

Is there any way to get the regex of the long-lived branch defined?

Thanks!

Hi @ricardf

The regexp is stored in a project settings. You can use WS api/settings/values to get value of sonar.branch.longLivedBranches.regex.

Hi @Julien_HENRY !

Thanks for the answer, whats happening is that the project might have a different regex than the one configured in global settings.

Can this value be read project-based? Also, when analyzing for first time, can I set a value on that regex regarding the project?

Hi,

both WS
api/settings/values for reading settings values
api/setttings/set for setting values
have a component parameter that takes the projectktey.
See https://yoursonarhost/web_api for details.

Regards,
Gilbert

1 Like

The best option to avoid default global value is to provision the project first (using WS) and set a value as mentioned by @Rebse

Thanks! worked perfectly !

Now i’m trying to do the same thing for webhooks, I asume i have to use the /api/webhooks