mcpField
G
gitlab-ci

gitlab-ci

github.com/grandcamelクラウド・DevOps4103 回インストール40 週間前に更新
リポジトリ

gitlab-ci について

gitlab-ciは、`glab` CLIでGitLab CI/CDパイプラインを操作するスキルです。パイプラインの監視、ジョブの調査、設定の検証、アーティファクトのダウンロードを扱います。

主な機能

  1. 01パイプライン状態の確認と絞り込み
  2. 02パイプライン実行やジョブ再試行
  3. 03ジョブログの確認
  4. 04パイプライン成果物のダウンロード
  5. 05CI設定の検証

活用シーン

  1. 01ブランチのビルド状態を確認
  2. 02ログから失敗ジョブを調査
  3. 03デプロイパイプラインを実行・監視
  4. 04ビルド成果物をダウンロード

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/grandcamel/gitlab-assistant-skills --skill gitlab-ci

インストール後、Claude Code で/gitlab-ciを入力して読み込まれたか確認します。

詳細

CI/CD パイプラインのスキル

glab CLI を使用した GitLab の CI/CD パイプライン操作です。

クイックリファレンス

操作コマンドリスク
ステータスを表示glab ci status-
パイプラインを表示glab ci view-
パイプラインを一覧表示glab ci list-
パイプラインを実行glab ci run⚠️
パイプラインの JSON を取得glab ci get-
ジョブを再試行glab ci retry <job-id>⚠️
ジョブのログを表示glab ci trace <job-id>-
アーティファクトをダウンロードglab ci artifact-
CI 設定をリントglab ci lint-
パイプラインを削除glab ci delete <id>⚠️⚠️

リスク凡例:- 安全 | ⚠️ 注意 | ⚠️⚠️ 警告 | ⚠️⚠️⚠️ 危険

このスキルを使うタイミング

必ず使用する場合:

  • パイプライン/ビルドのステータスを確認したい場合
  • 「CI」、「CD」、「pipeline」、「build」、「job」、「deploy」について言及した場合
  • ビルドを開始または再試行したい場合
  • ジョブのログを表示したい場合

使用しない場合:

  • CI/CD 変数を管理したい場合(代わりに gitlab-variable を使用してください)
  • スケジュールを管理したい場合(代わりに gitlab-schedule スキルを使用してください)

使用可能なコマンド

パイプラインのステータスを表示
glab ci status [options]

オプション:

フラグ説明
-b, --branch=<branch>特定のブランチのステータスを確認します
-l, --liveステータスをリアルタイムで表示します(自動更新)
-c, --compactコンパクト表示にします

例:

# View current branch pipeline status
glab ci status

# View status for specific branch
glab ci status --branch=main

# Watch status live (updates in real-time)
glab ci status --live

# Compact view
glab ci status --compact
パイプラインのインタラクティブ表示
glab ci view [options]

オプション:

フラグ説明
-b, --branch=<branch>特定のブランチ/タグのパイプラインを表示します
-p, --pipeline-id=<id>ID を指定して特定のパイプラインを表示します
-w, --webブラウザーでパイプラインを開きます

表示モードでのキーボードショートカット:

キー操作
Esc または qログを閉じる、またはパイプラインに戻る
Ctrl+R または Ctrl+Pジョブを実行、再試行、または再生する
Tab /矢印キー移動する
Enter選択を確定する
Ctrl+Dジョブをキャンセル/表示を終了する

例:

# Interactive view for current branch
glab ci view

# View specific branch pipeline
glab ci view --branch=feature/new

# View specific pipeline ID
glab ci view --pipeline-id=12345

# Open in browser
glab ci view --web
パイプラインを一覧表示
glab ci list [options]

オプション:

フラグ説明
-b, --branch=<branch>ブランチで絞り込みます
--status=<status>ステータスで絞り込みます:running、pending、success、failed、canceled、skipped
--allすべてのパイプラインを一覧表示します(デフォルトページのみではありません)
-P, --per-page=<n>1 ページあたりの項目数

例:

# List recent pipelines
glab ci list

# List pipelines for branch
glab ci list --branch=main

# List failed pipelines
glab ci list --status=failed

# List all running pipelines
glab ci list --status=running --all
パイプラインを実行/トリガー
glab ci run [options]

オプション:

フラグ説明
-b, --branch=<ref>パイプラインを実行するブランチまたはタグ
--variables=<vars>key=value のペアで指定する CI 変数(カンマ区切り)

例:

# Run pipeline for current branch
glab ci run

# Run pipeline for specific branch
glab ci run --branch=main

# Run with CI variables
glab ci run --variables="DEPLOY_ENV=staging,DEBUG=true"

# Run for a tag
glab ci run --branch=v1.2.3
パイプラインの JSON を取得
glab ci get [options]

パイプラインの JSON 表現を取得します。

オプション:

フラグ説明
-b, --branch=<branch>特定のブランチのパイプラインを取得します
-p, --pipeline-id=<id>ID を指定して特定のパイプラインを取得します

例:

# Get current branch pipeline
glab ci get

# Get specific pipeline
glab ci get --pipeline-id=12345

# Pipe to jq for processing
glab ci get | jq '.status'
ジョブを再試行
glab ci retry <job-id>

失敗した CI ジョブを再試行します。

例:

# Retry specific job
glab ci retry 456789
ジョブログを追跡
glab ci trace <job-id> [options]

ジョブログをリアルタイムで表示します。

例:

# Trace job output
glab ci trace 456789
アーティファクトをダウンロード
glab ci artifact [options]

最後のパイプラインからアーティファクトをダウンロードします。

オプション:

フラグ説明
-b, --branch=<branch>特定のブランチからダウンロードします
-j, --job=<job-name>特定のジョブからダウンロードします
-p, --path=<path>指定したパスにダウンロードします

例:

# Download all artifacts from last pipeline
glab ci artifact

# Download from specific job
glab ci artifact --job=build

# Download to specific directory
glab ci artifact --path=./artifacts/
CI 設定をリント
glab ci lint [file]

.gitlab-ci.yml ファイルを検証します。

例:

# Lint default .gitlab-ci.yml
glab ci lint

# Lint specific file
glab ci lint path/to/.gitlab-ci.yml
パイプラインを削除
glab ci delete <pipeline-id>

**警告:**これにより、パイプラインとそのジョブが完全に削除されます。

一般的なワークフロー

ワークフロー 1:失敗したパイプラインの確認と修正
# 1. Check current status
glab ci status

# 2. View failed pipeline interactively
glab ci view

# 3. Find failed job and view logs (in interactive view)
# Press arrow keys to select job, Enter to view logs

# 4. Retry the failed job
glab ci retry <job-id>

# 5. Watch the retry
glab ci status --live
ワークフロー 2:デプロイをトリガー
# 1. Ensure tests pass
glab ci status --branch=main

# 2. Trigger deployment pipeline with variables
glab ci run --branch=main --variables="DEPLOY_ENV=production"

# 3. Monitor deployment
glab ci status --live
ワークフロー 3:CI 設定をデバッグ
# 1. Lint your CI config
glab ci lint

# 2. If valid, run a test pipeline
glab ci run

# 3. Watch the results
glab ci view
ワークフロー 4:ビルドアーティファクトをダウンロード
# 1. Check pipeline succeeded
glab ci status --branch=release

# 2. Download artifacts from build job
glab ci artifact --branch=release --job=build --path=./dist/

パイプラインのステータス一覧

ステータス意味
runningパイプラインを実行中です
pendingパイプラインの実行待ちです
successすべてのジョブが成功しました
failed1 つ以上のジョブが失敗しました
canceledパイプラインは手動でキャンセルされました
skippedパイプラインはスキップされました
manual手動でのトリガー待ちです
scheduled後で実行されるようスケジュールされています

トラブルシューティング

問題原因解決策
認証に失敗するトークンが無効または期限切れですglab auth login を実行してください
パイプラインが見つからないブランチのパイプラインがありませんブランチ名を確認するか、glab ci run を実行してください
ジョブが保留中のままになる利用可能なランナーがありませんランナーの設定を確認してください
Lint に失敗するYAML の構文が無効です.gitlab-ci.yml の構文エラーを修正してください
再試行できないジョブが再試行可能な状態ではありません現在の実行が終わるまで待つか、先にキャンセルしてください

関連ドキュメント

コメント