gitlab-users

CI Latest Release Python Version License: MIT Code style: black Doc

A CLI and an API to manage GitLab user accounts, based on python-gitlab.

Features

  • List users and groups from a GitLab instance

  • Export users to CSV

  • Bulk create/delete users from CSV

  • Export SSH keys

Installation

pip install gitlab-users

Requires Python 3.9+ and a valid python-gitlab configuration (~/.python-gitlab.cfg).

Usage

Get help and list all commands:

gitlab-users -h

List all users:

gitlab-users list-users

List all groups:

gitlab-users list-groups

Export all users to a CSV file:

gitlab-users export-users users.csv

Create users from a CSV file (see example format below):

gitlab-users create-from-csv users.csv

Delete users from a CSV/text file (usernames in first column):

gitlab-users delete-from-csv users.csv

Delete a single user (asks for confirmation):

gitlab-users delete-user USERNAME

Export SSH keys of a user:

gitlab-users export-ssh-keys USERNAME

Example CSV format

# username, name, email, [organization], [location], [group], [access_level]
# Note: The fields in square brackets are optional and can be omitted if not needed.
ww,Diana Prince,wonder.woman@themyscira.org,,Themyscira
wayne,Bruce Wayne,bruce.wayne@wayne-enterprises.com,Wayne Enterprises,Gotham City,board,owner

Development

  • See CONTRIBUTING.md for dev setup, linting, testing, and release instructions.

  • Run all tests: pytest

  • Lint and format: ruff check . and black .

Documentation

  • Full API and usage documentation: Sphinx HTML docs

  • To build locally:

    cd docs
    make html
    

License

MIT License

Table of contents