A command line tool for bulk GitLab operations

This post presents a new GitLab tool called gitlab-tools .

It is a command line tool supports bulk operations:

Add a list of users to a group with Reporter role. Add a group as a member to all projects that have a given name. Print details of projects that have a given name. Submit specific files to MOSS for plagiarism detection (for teaching/assessing programming).

It is open source: https://gitlab.com/robstewart57/gitlab-tools

Please see the README file in that GitLab project for installation instructions.

Add users to a group

First create a CSV file, e.g. users.csv , with comma separated GitLab user IDs that you want to add to a GitLab group.

Let's say we want to add them to a group called WebDevelopers , this command will add all users to that group with the role of Reporter:

gitlab-tools \ --host https://gitlab.example.com \ --token mytoken12345 \ --userFilename users.csv \ --add-reporters-to-group \ --group WebDevelopers

Adding a group to multiple projects

Let's say we want to add a group as a Reporter, e.g. CodeReviewers , to all projects that have a given name, e.g. BackendDatabase :

gitlab-tools \ --host https://gitlab.example.com \ --token mytoken12345 \ --share-projects-with-group \ --project BackendDatabase \ --group CodeReviewers

Printing details for projects

Let's say we want to list details about all projects with the name Tetris :

gitlab-tools \ --host https://gitlab.example.com \ --token mytoken12345 \ --projectDetails \ --project Tetris

It'll report:

Continuous Integration result for the most recent commit.

How many members the project has.

The visibility of the project (private, internal or public).

How many commits the project has.

For example:

finding details for project: Tetris user1/Tetris : passing, 1 members, visibility private, 35 commits. user2/Tetris : failing, 1 members, visibility private, 1 commits. user3/Tetris : failing, 1 members, visibility private, 8 commits. ...

Creating a GitLab Access Token

Before using this tool, you first create an access token using the GitLab web interface.

Go to your profile on the GitLab server you are using, e.g. https://gitlab.example.com/profile, replacing the domain name with your GitLab instance URL.

Click Access Tokens on the left. Then click Create personal access token.

Keep a record of the token, it is needed by the --token flag.

Summary

The gitlab-tools command line tool allows to perform bulk GitLab operations. It is useful to automate changes on GitLab instances with hundreds/thousands of users. It also integrates the MOSS plagiarism detection service, which is useful when detecting code plagiarism in the context of assessed programming in an educational setting. See this for more details.

This gitlab-tools software has been implemented using the gitlab-haskell library (details), which uses the GitLab REST API.

If you have questions, discover any bugs, or wish to request a feature, please do so here: https://gitlab.com/robstewart57/gitlab-tools/issues