tags:

views:

33

answers:

2

Is it possible to create a new user in sonar without using the web interface? I need to write a script that inserts the same users for some tools, including sonar.

A: 

The web service API does not seem to support user management. Anything's possible, but it doesn't look like this is offered directly via Sonar.

You could probably use some web automation library (webbrowser, webunit, watir, twill) to do it through the running server; it might even be possible to just use something like 'curl' by looking carefully at the page source for the users/create form.

Or, if you want to go straight to the database, you could try to pull out the user creation functionality from the code and mess with the sonar.users table directly.

There is the LDAP Plugin, which would take care of authentication, but it still requires you to create the users in Sonar, so that wouldn't solve your problem.

Zac Thompson
The LDAP Plugin has a switch that allows automatic user creation.
shipmaster
thanks, @shipmaster, I missed that somehow.
Zac Thompson
+1  A: 

There are three ways you can do this:

  1. Write directly to the database (there is a simple table called users).

  2. Use the LDAP plugin, if you specify sonar.authenticator.createUsers: true in sonar.properties, it will create the users in the sonar database automatically the first time they authenticate.

  3. Write a java application that depends on the sonar plugin API, you can then use constructor injection to get a Sonar hibernate session and persist the user you want. See Here.

shipmaster
If it were me I would definitely go with the LDAP plugin.
Zac Thompson