Azure DevOps 連携
このプラグインのインストール手順と完全なMarkdownガイドを含むセットアッププロンプトをコピー
code の変更をプッシュするたびに、Capgo Live Updates を Azure DevOps Pipelines と連携してアプリのアップデートを自動デプロイしましょう。このガイドでは、ビルド、テスト、デプロイの自動化ワークフローのセットアップ方法を解説します。
前提条件
「前提条件」セクションAzure DevOps 連携を設定する前に、以下を確認してください:
- Azure DevOps の組織とプロジェクト
- アプリが設定済みの Capgo アカウント
- Azure Repos Git リポジトリ内のアプリの code ソース
- プロジェクトに設定された Node.js と npm/yarn
Azure DevOps パイプラインの設定
「Azure DevOps パイプラインの設定」セクションステップ 1: パイプライン変数の作成
「ステップ 1: パイプライン変数の作成」セクションまず、Azure DevOps プロジェクトに必要な変数を設定します:
- Azure DevOps プロジェクトに移動します
- 以下にアクセスして Pipelines → Library → 変数グループ
- 次の名前で新しい variable group を作成します:
Capgo-Variables - 以下の変数を追加してください:
| 変数名 | 値 | Secure |
|---|---|---|
CAPGO_TOKEN | Capgo API トークン | ✅ はい |
シンプル
「シンプル」セクションmainブランチへのプッシュごとに、本番環境へデプロイする基本設定:
# Simple Azure DevOps Pipeline for Capgo Live Updatestrigger: branches: include: - main
variables: - group: Capgo-Variables
jobs: - job: BuildAndDeploy displayName: 'Build and Deploy to Capgo' pool: vmImage: 'ubuntu-latest'
steps: - task: NodeTool@0 displayName: 'Setup Node.js' inputs: versionSpec: '22.x'
- script: | npm ci npm run test npm run build displayName: 'Install, test and build'
- script: | npm install -g @capgo/cli npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel production displayName: 'Deploy to Capgo'高度な設定
「高度な設定」セクションフィーチャーブランチのデプロイ
「フィーチャーブランチのデプロイ」というセクションレビューやテスト用に、フィーチャーブランチをテスト用チャンネルへデプロイします:
# Feature branch deploymenttrigger: branches: include: - feature/*
variables: - group: Capgo-Variables
jobs: - job: DeployFeature displayName: 'Deploy Feature Branch' pool: vmImage: 'ubuntu-latest' condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/feature/')
steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- script: | npm ci npm run test npm run build displayName: 'Install, test and build'
- script: | BRANCH_NAME=$(echo "$(Build.SourceBranchName)" | sed 's/[^a-zA-Z0-9-]/-/g') CHANNEL_NAME="feature-$BRANCH_NAME" npm install -g @capgo/cli npx @capgo/cli channel add $CHANNEL_NAME --apikey $(CAPGO_TOKEN) || true npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel $CHANNEL_NAME displayName: 'Deploy to Feature Channel'暗号化の使用
「暗号化の使用」というタイトルのセクションもし Capgo の暗号化機能を使用しているなら、CI/CD 環境に秘密鍵を安全に保存する必要があります。
ローカルで 暗号化キーを設定した後、 ローカル環境で、プライベートキーを Azure DevOps の変数に追加します:
# Display your private key content (copy this output)cat .capgo_key_v2以下の内容を CAPGO_PRIVATE_KEY Azure DevOps の変数グループに追加(Secretとして設定)し、パイプラインで使用してください:
# Deploy with encryption- script: | npm install -g @capgo/cli npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --key-data-v2 "$(CAPGO_PRIVATE_KEY)" --channel production displayName: 'Deploy to Capgo with Encryption'マルチチャネル設定
「マルチチャネル設定」セクション複数のデプロイチャネルのセットアップと管理に関する詳細は、 Channelsドキュメント.
複数環境とプルリクエストデプロイを含む完全な設定:
# Advanced Azure DevOps Pipeline with Multiple Channelstrigger: branches: include: - main - develop
pr: branches: include: - main - develop
variables: - group: Capgo-Variables
stages: # Build stage - stage: Build jobs: - job: BuildApp pool: vmImage: 'ubuntu-latest' steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- script: | npm ci npm run test npm run build displayName: 'Install, test and build'
- task: PublishBuildArtifacts@1 inputs: pathToPublish: 'dist' artifactName: 'app-build'
# Deploy to development - stage: DeployDev condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) jobs: - deployment: DeployDevelopment environment: development pool: vmImage: 'ubuntu-latest' strategy: runOnce: deploy: steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- task: DownloadBuildArtifacts@0 inputs: artifactName: 'app-build' downloadPath: '$(Pipeline.Workspace)'
- script: | npm install -g @capgo/cli npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel development --path $(Pipeline.Workspace)/app-build displayName: 'Deploy to Development'
# Deploy PR to test channel - stage: DeployPR condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) jobs: - job: DeployPRChannel pool: vmImage: 'ubuntu-latest' steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- task: DownloadBuildArtifacts@0 inputs: artifactName: 'app-build' downloadPath: '$(Pipeline.Workspace)'
- script: | CHANNEL_NAME="pr-$(System.PullRequest.PullRequestNumber)" npm install -g @capgo/cli npx @capgo/cli channel add $CHANNEL_NAME --apikey $(CAPGO_TOKEN) || true npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel $CHANNEL_NAME --path $(Pipeline.Workspace)/app-build displayName: 'Deploy to PR Channel'
# Deploy to production - stage: DeployProd condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) jobs: - deployment: DeployProduction environment: production pool: vmImage: 'ubuntu-latest' strategy: runOnce: deploy: steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- task: DownloadBuildArtifacts@0 inputs: artifactName: 'app-build' downloadPath: '$(Pipeline.Workspace)'
- script: | npm install -g @capgo/cli npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel production --path $(Pipeline.Workspace)/app-build displayName: 'Deploy to Production'マルチ環境デプロイ
「マルチ環境デプロイ」セクション複数の環境を扱う複雑なシナリオの場合:
# Extended pipeline with multiple environmentsparameters: - name: deployEnvironment displayName: 'Deploy Environment' type: string default: 'staging' values: - staging - production
variables: - group: Capgo-Variables - name: channelName ${{ if eq(parameters.deployEnvironment, 'production') }}: value: 'production' ${{ else }}: value: 'staging'
stages: # Build stage - stage: Build jobs: - job: BuildApp pool: vmImage: 'ubuntu-latest' steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- script: | npm ci npm run test npm run build displayName: 'Install, test and build'
- task: PublishBuildArtifacts@1 inputs: pathToPublish: 'dist' artifactName: 'app-build'
- stage: DeployStaging displayName: 'Deploy to Staging' dependsOn: Build condition: and(succeeded(), eq('${{ parameters.deployEnvironment }}', 'staging')) jobs: - deployment: DeployStaging displayName: 'Deploy to Staging Channel' pool: vmImage: 'ubuntu-latest' environment: 'staging' strategy: runOnce: deploy: steps: - template: deploy-steps.yml parameters: channel: 'staging'
- stage: DeployProduction displayName: 'Deploy to Production' dependsOn: Build condition: and(succeeded(), eq('${{ parameters.deployEnvironment }}', 'production')) jobs: - deployment: DeployProduction displayName: 'Deploy to Production Channel' pool: vmImage: 'ubuntu-latest' environment: 'production' strategy: runOnce: deploy: steps: - template: deploy-steps.yml parameters: channel: 'production'デプロイ用テンプレート (deploy-steps.yml)
「デプロイ用テンプレート (deploy-steps.yml)」セクション再利用可能なテンプレートファイルを作成する deploy-steps.yml:
parameters: - name: channel type: string
steps: - task: NodeTool@0 displayName: 'Install Node.js' inputs: versionSpec: '22.x'
- task: DownloadBuildArtifacts@0 displayName: 'Download build artifacts' inputs: artifactName: 'app-build' downloadPath: '$(System.ArtifactsDirectory)'
- script: | npm install -g @capgo/cli displayName: 'Install Capgo CLI'
- script: | npx @capgo/cli bundle upload \ --apikey $(CAPGO_TOKEN) \ --channel ${{ parameters.channel }} \ --path $(System.ArtifactsDirectory)/app-build displayName: 'Upload to Capgo (${{ parameters.channel }})'ブランチベースのデプロイ戦略
「ブランチベースのデプロイ戦略」セクションGitブランチに基づいて異なるデプロイ戦略を設定します:
trigger: branches: include: - main - develop - feature/*
variables: - group: Capgo-Variables - name: targetChannel ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}: value: 'production' ${{ elseif eq(variables['Build.SourceBranch'], 'refs/heads/develop') }}: value: 'staging' ${{ else }}: value: 'development'
stages: - stage: Build jobs: - job: BuildApp pool: vmImage: 'ubuntu-latest' steps: - task: NodeTool@0 inputs: versionSpec: '22.x'
- script: | npm ci npm run test npm run build displayName: 'Install, test and build'
- task: PublishBuildArtifacts@1 inputs: pathToPublish: 'dist' artifactName: 'app-build'
- stage: Deploy displayName: 'Deploy to $(targetChannel)' dependsOn: Build condition: succeeded() jobs: - deployment: DeployJob displayName: 'Deploy to $(targetChannel) Channel' pool: vmImage: 'ubuntu-latest' environment: '$(targetChannel)' strategy: runOnce: deploy: steps: - template: deploy-steps.yml parameters: channel: '$(targetChannel)'セキュリティのベストプラクティス
「セキュリティのベストプラクティス」セクション安全な変数管理
「安全な変数管理」セクション- 変数グループの活用: 機密データは Azure DevOps の変数グループに保存する
- シークレットとしてマーク: API のトークンやキーは、常にシークレット変数としてマークしてください
- アクセスのスコープ制限: 変数グループへのアクセスを、特定のパイプラインやユーザーのみに制限する
- キーのローテーション: Capgo の API トークンは定期的にローテーションしてください
モニタリングと通知
「モニタリングと通知」のセクションTeams連携
「Teams連携」のセクションパイプラインにMicrosoft Teams通知を追加するには:
- task: ms-teams-deploy-card@1.4.1 displayName: 'Notify Teams on Success' condition: succeeded() inputs: webhookUri: '$(TEAMS_WEBHOOK_URL)' title: 'Capgo Deployment Successful' text: 'App deployed to $(targetChannel) channel' themeColor: '00FF00'
- task: ms-teams-deploy-card@1.4.1 displayName: 'Notify Teams on Failure' condition: failed() inputs: webhookUri: '$(TEAMS_WEBHOOK_URL)' title: 'Capgo Deployment Failed' text: 'Deployment to $(targetChannel) failed' themeColor: 'FF0000'メール通知
「メール通知」のセクションデプロイ状況のメール通知を設定するには:
- task: EmailReport@1 displayName: 'Send Email Report' condition: always() inputs: sendMailConditionConfig: 'Always' subject: 'Capgo Deployment Report - $(Build.BuildNumber)' to: 'team@yourcompany.com' body: | Deployment Status: $(Agent.JobStatus) Channel: $(targetChannel) Build: $(Build.BuildNumber) Commit: $(Build.SourceVersion)トラブルシューティング
「トラブルシューティング」セクションよくある問題
「よくある問題」セクション「Capgo CLI not found」というエラーでパイプラインが失敗する場合:
# Ensure global installation- script: | npm install -g @capgo/cli which capgo || echo "Capgo CLI not found in PATH" displayName: 'Install and verify Capgo CLI'認証エラー:
# Verify token is correctly set- script: | echo "Token length: ${#CAPGO_TOKEN}" if [ -z "$CAPGO_TOKEN" ]; then echo "CAPGO_TOKEN is not set" exit 1 fi displayName: 'Verify Capgo token' env: CAPGO_TOKEN: $(CAPGO_TOKEN)ビルド成果物が見つからない場合:
# List available artifacts for debugging- script: | ls -la $(System.ArtifactsDirectory) find $(System.ArtifactsDirectory) -name "*.js" -o -name "*.html" displayName: 'Debug artifacts'パイプラインのデバッグ
「パイプラインのデバッグ」セクション問題をトラブルシューティングするためのデバッグ手順を追加します:
- script: | echo "Build.SourceBranch: $(Build.SourceBranch)" echo "Build.BuildNumber: $(Build.BuildNumber)" echo "Target Channel: $(targetChannel)" displayName: 'Debug Pipeline Variables'
- script: | npx @capgo/cli app debug --apikey $(CAPGO_TOKEN) displayName: 'Debug Capgo App Status'次のステップ
「Next Steps」セクション- 詳細を見る チャネル 異なるデプロイ環境を管理するには
- 詳しく見る カスタムストレージ 高度なデプロイシナリオ向け
- セットアップ 暗号化 セキュアなデプロイのために
- 設定 Updateの挙動 アップデートの適用方法をカスタマイズする
Azure DevOpsとの連携により、Capgoのデプロイを自動化し、モバイルアプリのユーザーへ一貫性のある信頼できるアップデートを確実に提供できます。
Azure DevOps連携の次のステップ
「Azure DevOps連携の次のステップ」というタイトルのセクション以下を使用している場合: Azure DevOps 連携 CI/CD 自動化を計画するには、次と接続します: Capgo による CI/CD Capgo CI/CD のプロダクトワークフロー向けに、 Capgo Native Build Capgo Native Builds のプロダクトワークフロー向けに、 Capgo 連携一覧 Capgo Integrations のプロダクトワークフロー向けに、 CI/CD 連携 CI/CD Integration の実装詳細向け、および GitHub Actions 連携 GitHub Actions Integration の実装詳細については。