A simple command-line tool to interact with GitLab API. Currently only the version 4 of GitLab API is supported.
gitlab-cli provides a simple interface to interact with Gitlab servers. It has two main modes:
-
Interactive
provides a list of actions to choose from in an interactive way. -
Command
provides a single command line for user actions, arguments and flags.
- projects
- get list of projects
- get a project with id
- releases
- get list of releases of a project
- get a release with project id and tag name
- create a new release for a project
Gitlab authentication is done using Person Access Token. To generate a new token, go to "Gitlab > User Settings > Access Token".
The Gitlab base url and access token can be stored in a config file. The default location of the config file is $HOME/.gitlab-cli-config.yml
.
A Sample config file looks like this:
baseUrl: https://gitlabci.example.com
privateToken: 90we48534tgDFf345
In the interactive mode, gitlab-cli asks user the actions and parameters for each action in an interactive way.
In the command mode, user should enter the action and all the necessary arguments and flags together to perform the desired action. Example:
gitlab-cli project list --url <gitlab_base_url> --token <your_access_token>
to get list of projectsgitlab-cli release get --project-id <project_id> --tag-name <tag_name> --url <gitlab_base_url> --token <your_access_token>
to get a release with project id and tag namegitlab-cli release create '{"name":"release 0.0.1","tag_name":"0.0.1","description":"A nice description","ref":"master","released_at":"2019-09-12T11:04:05+02:00"}' --url <gitlab_base_url> --token <your_access_token> --project-id <project_id>
to create a new release
- Other actions can be added. Feel free to create pull requests or issues.
- Introduce profiles in the config file and receive the active profile as an argument. Example:
server1:
baseUrl: https://gitlabci.server1.com
privateToken: 90we48534tgDFf345
server2:
baseUrl: https://gitlabci.server2.com
privateToken: 24r58534t2gfg4671
- Add a new argument to override the location of the config file.
go build -o gitlab-cli
Optionally you can set the version number:
go build -o gitlab-cli -ldflags "-X https://github.com/EXXETA/gitlab-cli/cmd.Version=x.y.z"
go test -v ./...
go run gitlab-cli
or
./gitlab-cli