azure-pipelines について
VS Code の開発者向けに、Azure CLI とリポジトリのスクリプトを使った Azure Pipelines の変更検証を案内するスキルです。ビルドの登録、監視、調査、キャンセルを扱います。
主な機能
- 01パラメーターを指定したビルド登録
- 02ビルド状態の確認と監視
- 03ログとアーティファクトのダウンロード
- 04ドライラン対応のビルドキャンセル
- 05ブランチ上のパイプライン変更検証
活用シーン
- 01パイプライン YAML の変更テスト
- 02対象を絞った CI ビルドの実行
- 03ログを使ったビルド失敗の調査
- 04不要になったブランチビルドの停止
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ microsoft/ vscode --skill azure-pipelinesインストール後、Claude Code で/azure-pipelinesを入力して読み込まれたか確認します。
同梱ファイルazure-pipeline.ts
詳細
Azure Pipeline の変更の検証
Azure DevOps のパイプラインファイル(build/azure-pipelines/ 内の YAML ファイル)を変更する場合、コミット前に Azure CLI を使って変更をローカルで検証できます。変更をプッシュして CI を待ち、結果を確認するという時間のかかるフィードバックループを避けられます。
前提条件
-
Azure CLI がインストールされているか確認します:
az --versionインストールされていない場合は、インストールします:
# macOS brew install azure-cli # Windows (PowerShell as Administrator) winget install Microsoft.AzureCLI # Linux (Debian/Ubuntu) curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash -
DevOps 拡張機能がインストールされているか確認します:
az extension show --name azure-devopsインストールされていない場合は、追加します:
az extension add --name azure-devops -
認証します:
az login az devops configure --defaults organization=https://dev.azure.com/monacotools project=Monaco
VS Code のメインビルド
VS Code のメインビルドパイプライン:
- 組織:
monacotools - プロジェクト:
Monaco - 定義 ID:
111 - URL:https://dev.azure.com/monacotools/Monaco/_build?definitionId=111
VS Code Insider のスケジュールビルド
2 つの Insider ビルドがスケジュールに従って自動実行されます:
- 朝のビルド:午前 7 時頃(CET)
- 夜のビルド:午後 7 時頃(CET)
これらのスケジュールビルドでは同じパイプライン定義(111)を使用しますが、Insider リリースを作成するため、main ブランチで実行されます。
ビルドのキュー登録
キュー登録コマンドを使って検証ビルドをキューに登録します:
# Queue a build on the current branch
node .github/skills/azure-pipelines/azure-pipeline.ts queue
# Queue with a specific source branch
node .github/skills/azure-pipelines/azure-pipeline.ts queue --branch my-feature-branch
# Queue with custom parameters
node .github/skills/azure-pipelines/azure-pipeline.ts queue --parameter "VSCODE_BUILD_WEB=false" --parameter "VSCODE_PUBLISH=false"
# Parameter value with spaces
node .github/skills/azure-pipelines/azure-pipeline.ts queue --parameter "VSCODE_BUILD_TYPE=Product Build"
重要:新しいビルドをキューに登録する前に、同じブランチで不要になった以前のビルドをキャンセルしてください。これにより、ビルドエージェントを解放し、リソースの浪費を減らせます:
# ステータスからビルド ID を確認し、キャンセルします node .github/skills/azure-pipelines/azure-pipeline.ts status node .github/skills/azure-pipelines/azure-pipeline.ts cancel --build-id <id> node .github/skills/azure-pipelines/azure-pipeline.ts queue
スクリプトのオプション
| オプション | 説明 |
|---|---|
--branch <name> | ビルドするソースブランチ(デフォルト:現在の git ブランチ) |
--definition <id> | パイプライン定義 ID(デフォルト:111) |
--parameter <entry> | KEY=value 形式のパイプラインパラメーター(繰り返し指定可能)。値にスペースが含まれる場合はこちらを使用してください |
--parameters <list> | KEY=value KEY2=value2 形式の、スペース区切りのパラメーター。値にスペースを含めることはできません |
--dry-run | コマンドを実行せずに表示します |
製品ビルドキューのパラメーター(build/azure-pipelines/product-build.yml)
| 名前 | 型 | デフォルト | 使用可能な値 | 説明 |
|---|---|---|---|---|
VSCODE_QUALITY | string | insider | exploration、insider、stable | ビルド品質チャネル |
VSCODE_BUILD_TYPE | string | Product Build | Product、CI | 製品向けと CI 向けのビルドモード |
NPM_REGISTRY | string | https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/npm/registry/ | 任意の URL | カスタム npm レジストリ |
CARGO_REGISTRY | string | sparse+https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/Cargo/index/ | 任意の URL | カスタム Cargo レジストリ |
VSCODE_BUILD_WIN32 | boolean | true | true、false | Windows x64 をビルド |
VSCODE_BUILD_WIN32_ARM64 | boolean | true | true、false | Windows arm64 をビルド |
VSCODE_BUILD_LINUX | boolean | true | true、false | Linux x64 をビルド |
VSCODE_BUILD_LINUX_SNAP | boolean | true | true、false | Linux x64 Snap をビルド |
VSCODE_BUILD_LINUX_ARM64 | boolean | true | true、false | Linux arm64 をビルド |
VSCODE_BUILD_LINUX_ARMHF | boolean | true | true、false | Linux armhf をビルド |
VSCODE_BUILD_ALPINE | boolean | true | true、false | Alpine x64 をビルド |
VSCODE_BUILD_ALPINE_ARM64 | boolean | true | true、false | Alpine arm64 をビルド |
VSCODE_BUILD_MACOS | boolean | true | true、false | macOS x64 をビルド |
VSCODE_BUILD_MACOS_ARM64 | boolean | true | true、false | macOS arm64 をビルド |
VSCODE_BUILD_MACOS_UNIVERSAL | boolean | true | true、false | macOS ユニバーサル版をビルド(両方の macOS アーキテクチャが必要) |
VSCODE_BUILD_WEB | boolean | true | true、false | Web 成果物をビルド |
VSCODE_PUBLISH | boolean | true | true、false | builds.code.visualstudio.com に公開 |
VSCODE_RELEASE | boolean | false | true、false | 成功した場合にリリースフローを開始 |
VSCODE_STEP_ON_IT | boolean | false | true、false | テストをスキップ |
VSCODE_USE_LEGACY_OSS_NOTICE | boolean | false | true、false | Component Governance の通知の代わりに、従来の mixin ThirdPartyNotices.txt を使用 |
例:公開やリリースへの影響を最小限に抑えて、CI 向けの検証をすばやく実行します。
node .github/skills/azure-pipelines/azure-pipeline.ts queue \
--parameter "VSCODE_BUILD_TYPE=CI Build" \
--parameter "VSCODE_PUBLISH=false" \
--parameter "VSCODE_RELEASE=false"
ビルド状態の確認
実行中のビルドを監視するには、status コマンドを使用します。
# Get status of the most recent builds
node .github/skills/azure-pipelines/azure-pipeline.ts status
# Get overview of a specific build by ID
node .github/skills/azure-pipelines/azure-pipeline.ts status --build-id 123456
# Watch build status (refreshes every 30 seconds)
node .github/skills/azure-pipelines/azure-pipeline.ts status --watch
# Watch with custom interval (60 seconds)
node .github/skills/azure-pipelines/azure-pipeline.ts status --watch 60
スクリプトのオプション
| オプション | 説明 |
|---|---|
--build-id <id> | 特定のビルド ID(デフォルト:現在のブランチで最新のビルド) |
--branch <name> | ブランチ名でビルドを絞り込みます(そのブランチの直近 20 件を表示) |
--reason <reason> | 理由でビルドを絞り込みます:manual、individualCI、batchedCI、schedule、pullRequest |
--definition <id> | パイプライン定義 ID(デフォルト:111) |
--watch [seconds] | ビルドが完了するまで状態を継続的に確認します(デフォルト:30s) |
--download-log <id> | 指定したログを /tmp にダウンロード |
--download-artifact <name> | 成果物を /tmp にダウンロード |
--json | プログラムで処理するための生の JSON を出力 |
ビルドのキャンセル
実行中のビルドを停止するには、cancel コマンドを使用します。
# Cancel a build by ID (use status command to find IDs)
node .github/skills/azure-pipelines/azure-pipeline.ts cancel --build-id 123456
# Dry run (show what would be cancelled)
node .github/skills/azure-pipelines/azure-pipeline.ts cancel --build-id 123456 --dry-run
スクリプトのオプション
| オプション | 説明 |
|---|---|
--build-id <id> | キャンセルするビルド ID(必須) |
--definition <id> | パイプライン定義 ID(デフォルト:111) |
--dry-run | 実行せずに、キャンセルされる内容を表示 |
パイプラインの変更をテストする
ユーザーから Azure Pipelines のビルドで変更をテストする よう依頼された場合は、次のワークフローに従います。
- 現在のブランチで新しいビルドをキューに登録します
- ビルドが完了するまで、ビルド状態を定期的に確認して完了を待ちます
ビルド完了のポーリング
シェルループと sleep を使用して、ビルドのステータスをポーリングします。sleep コマンドは、主要なすべてのオペレーティングシステムで動作します。
# Queue the build and note the build ID from output (e.g., 123456)
node .github/skills/azure-pipelines/azure-pipeline.ts queue
# Poll every 60 seconds until complete (works on macOS, Linux, and Windows with Git Bash/WSL)
# Replace <BUILD_ID> with the actual build ID from the queue command
while true; do
node .github/skills/azure-pipelines/azure-pipeline.ts status --build-id <BUILD_ID> --json 2>/dev/null | grep -q '"status": "completed"' && break
sleep 60
done
# Check final result
node .github/skills/azure-pipelines/azure-pipeline.ts status --build-id <BUILD_ID>
または、ポーリングを自動的に処理する組み込みの --watch フラグを使用します。
node .github/skills/azure-pipelines/azure-pipeline.ts queue
# Use the build ID returned by the queue command
node .github/skills/azure-pipelines/azure-pipeline.ts status --build-id <BUILD_ID> --watch
注:デフォルトでは、
--watchフラグは30秒ごとにポーリングします。API 呼び出しを減らすには、60秒間隔の--watch 60を使用してください。
一般的なワークフロー
1. パイプラインのクイック検証
# Make your YAML changes, then:
git add -A && git commit -m "test: pipeline changes"
git push origin HEAD
# Check for any previous builds on this branch and cancel if needed
node .github/skills/azure-pipelines/azure-pipeline.ts status
node .github/skills/azure-pipelines/azure-pipeline.ts cancel --build-id <id> # if there's an active build
# Queue and watch the new build
node .github/skills/azure-pipelines/azure-pipeline.ts queue
node .github/skills/azure-pipelines/azure-pipeline.ts status --watch
2. ビルドの調査
# Get overview of a build (shows stages, artifacts, and log IDs)
node .github/skills/azure-pipelines/azure-pipeline.ts status --build-id 123456
# Download a specific log for deeper inspection
node .github/skills/azure-pipelines/azure-pipeline.ts status --build-id 123456 --download-log 5
# Download an artifact
node .github/skills/azure-pipelines/azure-pipeline.ts status --build-id 123456 --download-artifact unsigned_vscode_cli_win32_x64_cli
3. パラメーターを変更してテスト
# Customize build matrix for quicker validation
node .github/skills/azure-pipelines/azure-pipeline.ts queue \
--parameter "VSCODE_BUILD_TYPE=CI Build" \
--parameter "VSCODE_BUILD_WEB=false" \
--parameter "VSCODE_BUILD_ALPINE=false" \
--parameter "VSCODE_BUILD_ALPINE_ARM64=false" \
--parameter "VSCODE_PUBLISH=false"
4. 実行中のビルドをキャンセル
# First, find the build ID
node .github/skills/azure-pipelines/azure-pipeline.ts status
# Cancel a specific build by ID
node .github/skills/azure-pipelines/azure-pipeline.ts cancel --build-id 123456
# Dry run to see what would be cancelled
node .github/skills/azure-pipelines/azure-pipeline.ts cancel --build-id 123456 --dry-run
5. パイプラインの変更を反復
パイプライン YAML の変更を反復する際は、新しいビルドをキューに追加する前に、必ず古いビルドをキャンセルしてください。
# Push new changes
git add -A && git commit --amend --no-edit
git push --force-with-lease origin HEAD
# Find the outdated build ID and cancel it
node .github/skills/azure-pipelines/azure-pipeline.ts status
node .github/skills/azure-pipelines/azure-pipeline.ts cancel --build-id <id>
# Queue a fresh build and monitor
node .github/skills/azure-pipelines/azure-pipeline.ts queue
node .github/skills/azure-pipelines/azure-pipeline.ts status --watch
トラブルシューティング
認証の問題
# Re-authenticate
az logout
az login
# Check current account
az account show
拡張機能が見つからない
az extension add --name azure-devops --upgrade
レート制限
レート制限に達した場合は、API 呼び出しの間に遅延を追加するか、より長い間隔を指定して --watch を使用してください。