Azure DevOps統合
このプラグインのセットアッププロンプトをコピーして、インストール手順とフルマークダウンガイドを取得します。
Azure DevOps PipelinesとCapgo Live Updatesを統合して、Capgoの更新を自動的にcodeの変更時に適用します。このガイドでは、自動ビルド、テスト、デプロイワークフローの設定について説明します。
Azure DevOps統合を設定する前に、次のことを確認してください。
- Azure DevOps組織とプロジェクト
- A Capgo アカウントにアプリが設定されている
- アプリのソース code をAzure Repos Git リポジトリに配置
- Node.js と npm/yarn がプロジェクト内で設定されている
Azure DevOps Pipelineの設定
セクション「Azure DevOps Pipelineの設定」ステップ 1: パイプライン変数の作成
セクション「ステップ 1: パイプライン変数の作成」最初に、Azure DevOps プロジェクト内で必要な変数を設定する必要があります。
- Azure DevOps プロジェクトに移動
- Go to Pipelines → Library → 変数グループ
- 新しい変数グループを__CAPGO_KEEP_0__ __CAPGO_KEEP_1__と名付けて作成
Capgo-Variables - 次の変数を追加する:
| 変数名 | 値 | 安全 |
|---|---|---|
CAPGO_TOKEN | Capgo APIトークンはこちら | ✅ はい |
__CAPGO_KEEP_1__
Section titled “__CAPGO_KEEP_2__”__CAPGO_KEEP_3__ から始まる基本的な設定:
# 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'__CAPGO_KEEP_4__
Section titled “__CAPGO_KEEP_5__”__CAPGO_KEEP_6__ から始まる高度な設定:
Copy to clipboard__CAPGO_KEEP_7__
# 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 create $CHANNEL_NAME --apikey $(CAPGO_TOKEN) || true npx @capgo/cli bundle upload --apikey $(CAPGO_TOKEN) --channel $CHANNEL_NAME displayName: 'Deploy to Feature Channel'暗号化の使用
「暗号化の使用」のセクションCapgoの暗号化機能を使用している場合 Capgo’s encryption feature後
暗号化キーを設定する __CAPGO_KEEP_0__ ローカルに、Azure DevOps変数にプライベートキーを追加してください:
# Display your private key content (copy this output)cat .capgo_key_v2Azure DevOps変数グループ(マークしてシークレット)に次の内容を追加してください: CAPGO_PRIVATE_KEY パイプラインで使用するには、ローカルに、Azure DevOps変数にプライベートキーを追加してください:
# 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'Multi-Channel Configuration
Multi-Channel ConfigurationCapgoの複数チャネル設定についての詳細情報は、 チャンネルドキュメント.
複数環境の設定とプルリクエストデプロイのための完全な構成:
# 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 create $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'Deployment Template (deploy-steps.yml)
展開テンプレート (deploy-steps.yml)__CAPGO_KEEP_0__ 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 }})'ブランチベース展開戦略
__CAPGO_KEEP_0____CAPGO_KEEP_0__
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)'セキュリティベストプラクティス
__CAPGO_KEEP_0__セキュアな変数管理
__CAPGO_KEEP_0__- 変数グループを使用する: Azure DevOpsの変数グループに機密情報を保存する
- 機密情報としてマークする: APIのトークンとキーは常に機密情報としてマークする
- アクセス範囲: 特定のパイプラインとユーザーに変数グループのアクセスを制限する
- キーを回転する: CapgoのAPIのトークンを定期的に回転する
監視と通知
「監視と通知」のセクションチーム統合
「チーム統合」のセクション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'デバッグ Pipelines
セクション「デバッグ Pipelines」問題をトラブルシューティングするためにデバッグステップを追加する:
- 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'次のステップ
セクション「次のステップ」- 学び チャンネル 異なるデプロイ環境を管理する
- Explore カスタムストレージ 高度なデプロイシナリオ向け
- セットアップ 暗号化 セキュアなデプロイ用
- 設定 更新動作 更新の適用方法をカスタマイズする
Azure DevOps統合により、Azure DevOpsから自動的にCapgoをデプロイし、モバイルアプリのユーザーに一貫した、信頼性の高い更新を保証できます。
Azure DevOps統合から続けてください
「Azure DevOps統合」から続けるあなたが「Azure DevOps統合」を使用している場合 「Azure DevOps統合」 CI/CDの自動化を計画するには、Azure DevOps統合を 「Capgo CI/CD」 「Capgo CI/CD」で製品ワークフローを 「Capgo Native Builds」 「Capgo Native Builds」で製品ワークフローを 「Capgo Integrations」 「Capgo Integrations」で製品ワークフローを CI/CD統合 CI/CD統合の実装詳細 GitHub アクション統合 GitHub アクション統合の実装詳細について