1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

🚀 Macに GitLab CLI コマンド glab をインストール

1
Posted at

Macに glab を Installする手順です

glab は、GitLab をターミナルから操作するための CLI ツールです。

ブラウザを開かなくても、Issue や Merge Request、CI/CD パイプライン、Release などをコマンドラインから扱えるようになります。

公式ドキュメント

公式リポジトリはこちらです。

インストール方法はこちらです。

インストール

Mac の場合

Homebrew でインストールできます。

brew install glab

インストール後、シェルが新しいコマンドを認識しないことがあるので、必要に応じて rehash を実行しておきます。

rehash

その後、インストールできたか確認します。

glab --version

バージョンが表示されれば OK です。

ログイン

インストールできたら、まずは GitLab にログインします。

glab auth login

対話形式で進むので、画面の案内に沿って設定していきます。

今回、自分の環境では以下のように進めました。

1. GitLab の接続先を選ぶ

┃ What GitLab instance do you want to sign in to?
┃ > gitlab.com
┃   GitLab Self-Managed or GitLab Dedicated instance

通常の GitLab.com を使う場合は gitlab.com を選べば大丈夫です。

2. サインイン方法を選ぶ

- Signing into gitlab.com
┃ How would you like to sign in?
┃   Token
┃ > Web

今回は Web を選びました。
ブラウザが開くので、そのまま認証を進めます。

3. コンテナレジストリ関連のドメイン確認

- Signing into gitlab.com
┃ What domains does this host use for the container registry and image dependency proxy?
┃ > gitlab.com,gitlab.com:443,registry.gitlab.com

ここはそのまま進めました。

4. デフォルトの Git protocol を選ぶ

- Signing into gitlab.com
┃ Choose default Git protocol:
┃ > SSH
┃   HTTPS
┃   HTTP

今回は SSH を選びました。

認証が完了すると、以下のように表示されます。

- Signing into gitlab.com
- glab config set -h gitlab.com git_protocol ssh
✓ Configured Git protocol.
- glab config set -h gitlab.com api_protocol https
✓ Configured API protocol.
✓ Logged in as Morykun
✓ Configuration saved xxxx.yml
  - Host: gitlab.com

これでログイン完了です。

認証状態を確認する

glab auth status

今どの GitLab に、どのユーザーでログインしているかを確認できます。

Issue を見る

Issue 一覧は以下で確認できます。

glab issue list

自分のプロジェクト配下の Issue 一覧を確認できます。

※ このコマンドは Git リポジトリの中で実行する必要があります。

Merge Request を見る

Merge Request の一覧は以下で確認できます。

glab mr list

詳細を見たいときは、たとえば以下のように実行できます。

glab mr view 123

123 の部分は Merge Request の番号です。

CI/CD パイプラインを見る

glab pipeline list

GitLab CI/CD のパイプライン一覧を確認できます。

どのパイプラインが成功していて、どれが失敗しているかをターミナルから見られるので便利です。

まとめ

GitLab を日常的に使っているなら、かなり相性がよさそうです。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?