Create new user in sonar

妖精的绣舞 提交于 2019-12-23 07:47:18

问题


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.


回答1:


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.




回答2:


Since SonarQube version 3.6, there is support for user management in webservice API: https://sonarqube.com/web_api/api/users

http://docs.sonarqube.org/display/DEV/Web+API




回答3:


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.



来源:https://stackoverflow.com/questions/3567257/create-new-user-in-sonar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!