Lishmael Lishmael - 4 years ago 595
Bash Question

Is there a way to add users automatically into gitlab?

I've got a gitlab running on server. For now, I've also got just a list of users and emails needed to be add into gitlab. Is there a way to do this automatically? (i.e. by script/service)

Answer Source

You can use the GitLab API to create users in a script. Recent versions of curl can url-encode POST data for you. Otherwise spaces will have to be %20 and --data instead of --data-urlencode.

curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" --data-urlencode "email=jon@doe.com&password=defaultpassword&username=jdoe&name=Jon Doe" "http://example.com/api/v3/users"

Curl is the path of least resistance with your preferred shell language (in my case Bash). If you don't want to use curl to script creating your users there are numerous libraries for different languages to interact with the GitLab API. Take your pick. Popular libraries include:

I'm sure there are many more API libs for other languages just google for your preferred language and include GitLab API as part of the query.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download