Sonarqube rest API query

684 views
Skip to first unread message

Bindu

unread,
Jun 7, 2017, 11:02:30 PM6/7/17
to SonarQube

Hi,

I am trying to use Sonarqube API to achieve the following:

1. Adding LDAP groups to specific project so that only users of that LDAP group will have access to that project.
2. Adding LDAP groups to administrator role

Are these operations exposed as part of the Sonarqube API's ?

If so, please can you share the documentation of Sonarqube rest API which explains about different endpoints exposed as part of the API and how we can use them.

Looking forward to your response.



Thank you.

colinh...@gmail.com

unread,
Jun 8, 2017, 12:14:11 AM6/8/17
to SonarQube

1. You can check to see if a group exists within SonarQube first by using GET api/user_groups/search (https://sonarcloud.io/web_api/api/user_groups)
2. If it doesn't exist, go ahead and add it using POST api/user_groups/create (https://sonarcloud.io/web_api/api/user_groups). If your LDAP is configured correctly, just having the group exist is all it needs to make the connection.
3. Should/when it does exist, add permissions to a project using POST api/permissions/add_group (https://sonarcloud.io/web_api/api/permissions)

Bindu

unread,
Jun 13, 2017, 1:32:48 PM6/13/17
to SonarQube, colinh...@gmail.com
Thanks colin, I was able to use the mentioned API`s for creating groups.

Now i am trying to use Sonarqube API for syncing all LDAP groups automatically which are created in LDAP and also want to associate LDAP groups to specific projects. Is there any API available for this operation ?
Looking forward to your response.


Julien Lancelot

unread,
Jun 14, 2017, 2:20:43 AM6/14/17
to Bindu, SonarQube, colinh...@gmail.com
Hi,

Why are you not using the Group Mapping feature of LDAP (https://docs.sonarqube.org/display/PLUG/LDAP+Plugin) ?

+++

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/704015c9-2baa-404b-813a-9bffe0eff779%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Julien Lancelot | SonarSource

Bindu Boinapalli

unread,
Jun 14, 2017, 9:42:00 AM6/14/17
to Julien Lancelot, SonarQube, colinh...@gmail.com
Hi Julien,

I already added LDAP Plugin in SonarQube and did configuration in sonar.properties but once i create new group in LDAP - I should also add that group manually in SonarQube dashboard. As we have 100`s of groups, i am looking for sonar API which helps in syncing all LDAP groups automatically which are created in LDAP.



Thank you.


On Wed, Jun 14, 2017 at 2:20 AM, Julien Lancelot <julien....@sonarsource.com> wrote:
Hi,

Why are you not using the Group Mapping feature of LDAP (https://docs.sonarqube.org/display/PLUG/LDAP+Plugin) ?

+++

On Tue, 13 Jun 2017 at 19:32 Bindu <bittu...@gmail.com> wrote:
Thanks colin, I was able to use the mentioned API`s for creating groups.

Now i am trying to use Sonarqube API for syncing all LDAP groups automatically which are created in LDAP and also want to associate LDAP groups to specific projects. Is there any API available for this operation ?
Looking forward to your response.


On Thursday, June 8, 2017 at 12:14:11 AM UTC-4, colinh...@gmail.com wrote:

1. You can check to see if a group exists within SonarQube first by using GET api/user_groups/search (https://sonarcloud.io/web_api/api/user_groups)
2. If it doesn't exist, go ahead and add it using POST api/user_groups/create (https://sonarcloud.io/web_api/api/user_groups). If your LDAP is configured correctly, just having the group exist is all it needs to make the connection.
3. Should/when it does exist, add permissions to a project using POST api/permissions/add_group (https://sonarcloud.io/web_api/api/permissions)

On Wednesday, June 7, 2017 at 11:02:30 PM UTC-4, Bindu wrote:

Hi,

I am trying to use Sonarqube API to achieve the following:

1. Adding LDAP groups to specific project so that only users of that LDAP group will have access to that project.
2. Adding LDAP groups to administrator role

Are these operations exposed as part of the Sonarqube API's ?

If so, please can you share the documentation of Sonarqube rest API which explains about different endpoints exposed as part of the API and how we can use them.

Looking forward to your response.



Thank you.

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+unsubscribe@googlegroups.com.

Julien Lancelot

unread,
Jun 15, 2017, 4:55:13 AM6/15/17
to Bindu Boinapalli, SonarQube, colinh...@gmail.com
Hi Bindu,

Ok I understand.

Than to reply to your last question : Now i am trying to use Sonarqube API for syncing all LDAP groups automatically which are created in LDAP and also want to associate LDAP groups to specific projects. Is there any API available for this operation ?

The answer is : use POST api/permissions/add_group (https://sonarcloud.io/web_api/api/permissions), as already suggested by Colin.

Regards,


To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
--
Julien Lancelot | SonarSource

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/CAFGxpZg%3DXOb6-xkScoRSoaLVXz%2Bxr-kM2qtkfE5HW2saoQtSxw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Bindu Boinapalli

unread,
Jun 15, 2017, 10:40:23 AM6/15/17
to Julien Lancelot, SonarQube, Colin Mueller
Hi Julien,

Yes i tried it, here is the output of my script.

[root@ip-177-22-599-7 linux-x86-64]# ./sync_groups.sh
Username: bp@gmail.com
Password: *****
Enter group name you want to add: so
group "so" does not exist in sonarqube, will add it now
group "so" is added to sonarqube


Inline image 1

Now i am looking for API that can sync groups automatically with out passing group name as parameter manually here when i am running script. I am planning to run the cron job daily. 



Thank you.

To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+unsubscribe@googlegroups.com.
--
Julien Lancelot | SonarSource

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages