Sign inSign up

cyd01/gitlabcli

By cyd01

•Updated about 1 month ago

A light client for Gitlab API v4

Image
Developer tools
0

2.4K

cyd01/gitlabcli repository overview

⁠Gitlab API client

⁠Description

This repository wraps this Gitlab API Go library⁠ and provides a command-line tool to manage a Gitlab⁠ instance.

⁠How to run

To run the Gitlab API client execute the following docker run command to get the client usage:

docker run --rm --interactive --tty cyd01/gitlabcli

⁠How to target your Gitlab instance

Set a GITLAB_URL environment variable with the URL of your Gitlab instance or use https://gitlab.com⁠ for the official Gitlab instance ;-)

export GITLAB_URL="https://gitlab.com"
docker run --rm --interactive --tty --env GITLAB_URL cyd01/gitlabcli broadcast ls
ID      Message                                                                     StartsAt            StartsAt            Active BroadcastType Dismissable
------- --------------------------------------------------------------------------- ------------------- ------------------- ------ ------------- -----------
 100719 GitLab open-sourced our remote work playbook. <a href="https://learn.git... 2020-04-22 15:38:00 2020-04-22 15:38:00  false notification        false
 100720 Hi {{name}}, <br />??GitLab.com is upgrading to 13.0, the next major rel... 2020-05-07 22:28:00 2020-05-07 22:28:00  false notification        false
...

Note: broadcast messages are the only API calls that do not require authentication.

⁠How to authenticate

⁠Authenticate with access token

If you need to authenticate to your Gitlab instance and you have an access token, simply set the GITLAB_TOKEN environment variable with this token.

export GITLAB_TOKEN="xxxxxxxxxxxxxxxxxxx"
docker run --rm --interactive --tty --env GITLAB_URL --env GITLAB_TOKEN cyd01/gitlabcli status get
Emoji       Message     
-------- ------------
grinning Hello world!
⁠Authenticate with usename and password

If your instance does not have 2FA enabled, it is possible to authenticate with username and password. Just set GITLAB_AUTH_USER and GITLAB_AUTH_PASS environment variables

export GITLAB_AUTH_USER="root"
export GITLAB_AUTH_PASS="yyyyyyyy"
docker run --rm --interactive --tty --env GITLAB_URL --env GITLAB_AUTH_USER --env GITLAB_AUTH_PASS cyd01/gitlabcli whoami
root

⁠About output formatting

By default this Gitlab API client prints results in a Docker-style well-formatted output.

There is a useful parameter option: -output-raw to print the original JSON response.

docker run --rm --interactive --tty --env GITLAB_URL --env GITLAB_TOKEN cyd01/gitlabcli status get -output-raw
{
    "emoji": "grinning",
    "availability": "not_set",
    "message": "Hello world!",
    "message_html": "Hello world!"
}

⁠Important information about real Gitlab.com

Gitlab.com⁠ service has so many users and projects, which means API requests can take a long time !

Use the -user username parameter option to restrict the request to your own user.

Tag summary

Content type

Image

Digest

sha256:bf86d453b…

Size

26.9 MB

Last updated

about 1 month ago

docker pull cyd01/gitlabcli