gitlab-ci について
gitlab-ciは、`glab` CLIでGitLab CI/CDパイプラインを操作するスキルです。パイプラインの監視、ジョブの調査、設定の検証、アーティファクトのダウンロードを扱います。
主な機能
- 01パイプライン状態の確認と絞り込み
- 02パイプライン実行やジョブ再試行
- 03ジョブログの確認
- 04パイプライン成果物のダウンロード
- 05CI設定の検証
活用シーン
- 01ブランチのビルド状態を確認
- 02ログから失敗ジョブを調査
- 03デプロイパイプラインを実行・監視
- 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 | すべてのジョブが成功しました |
failed | 1 つ以上のジョブが失敗しました |
canceled | パイプラインは手動でキャンセルされました |
skipped | パイプラインはスキップされました |
manual | 手動でのトリガー待ちです |
scheduled | 後で実行されるようスケジュールされています |
トラブルシューティング
| 問題 | 原因 | 解決策 |
|---|---|---|
| 認証に失敗する | トークンが無効または期限切れです | glab auth login を実行してください |
| パイプラインが見つからない | ブランチのパイプラインがありません | ブランチ名を確認するか、glab ci run を実行してください |
| ジョブが保留中のままになる | 利用可能なランナーがありません | ランナーの設定を確認してください |
| Lint に失敗する | YAML の構文が無効です | .gitlab-ci.yml の構文エラーを修正してください |
| 再試行できない | ジョブが再試行可能な状態ではありません | 現在の実行が終わるまで待つか、先にキャンセルしてください |
関連ドキュメント
コメント
Markdown 対応