Bitbucket Pipelines統合から続きます
__CAPGO_KEEP_0__のセットアッププロンプトをコピーするには、インストール手順とこのプラグインのフルマークダウンガイドを含めて。
Integrate Capgo Live Updates with Bitbucket Pipelines to automatically deploy your app updates whenever you push code changes. This guide covers setting up automated builds, testing, and deployment workflows.
Before setting up Bitbucket Pipelines integration, ensure you have:
- Bitbucketアカウントとリポジトリ
- Capgoアカウントとアプリの設定
- Node.jsとnpm/yarnがプロジェクトに設定されている
Bitbucket Pipelinesの設定
Bitbucket Pipelinesの設定ステップ 1: リポジトリ変数の設定
ステップ 1: リポジトリ変数の設定まず、Bitbucketリポジトリで必要な変数を設定してください。
- Bitbucketリポジトリに移動
- Go to リポジトリ設定 → PipeLine → リポジトリ変数
- 以下の変数を追加します。
| 変数名 | 値 | 暗号化 |
|---|---|---|
CAPGO_TOKEN | Your Capgo API token | ✅ はい |
シンプル
「シンプル」基本的な設定は、メインブランチにプッシュされるたびに、プロダクションにデプロイされます。
# bitbucket-pipelines.yml - Simple Configurationimage: node:22
pipelines: branches: main: - step: name: Build and Deploy to Production script: - npm ci - npm run test - npm run build - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel production artifacts: - dist/**高度
「高度」機能ブランチのデプロイ
「機能ブランチのデプロイ」機能ブランチをテストチャンネルにデプロイしてレビューとテストを行います。
# Feature branch deploymentpipelines: branches: feature/*: - step: name: Deploy Feature Branch script: - npm ci - npm run test - npm run build - BRANCH_NAME=$(echo $BITBUCKET_BRANCH | 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 artifacts: - dist/**暗号化の使用
「暗号化の使用」のセクションあなたが Capgoの暗号化機能を使用している場合、CI/CD環境で秘密鍵を安全に保存する必要があります。
暗号化キーを 設定した後 ローカルに、Bitbucket変数に秘密鍵を追加してください:
# Display your private key content (copy this output)cat .capgo_key_v2Bitbucketリポジトリの変数に追加 CAPGO_PRIVATE_KEY Bitbucketパイプラインで使用するには、次の内容をリポジトリの変数に追加してください (マークしてセキュア化してください):
# Deploy with encryption- step: name: Deploy to Capgo with Encryption script: - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --key-data-v2 "$CAPGO_PRIVATE_KEY" --channel productionMulti-Channel Configuration
Multi-Channel Configurationのセクション複数のデプロイチャンネルの設定と管理に関する詳細情報については、 チャンネルドキュメント.
複数の環境とプルリクエストデプロイの完全な構成:
# bitbucket-pipelines.yml - Advanced Multi-Channel Configurationimage: node:22
definitions: steps: - step: &build-step name: Build Application script: - npm ci - npm run test - npm run build artifacts: - dist/**
- step: &deploy-step name: Deploy to Capgo script: - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel $CHANNEL_NAME
pipelines: branches: main: - step: <<: *build-step - step: <<: *deploy-step name: Deploy to Production deployment: production trigger: manual script: - export CHANNEL_NAME=production - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel $CHANNEL_NAME
develop: - step: <<: *build-step - step: <<: *deploy-step name: Deploy to Development deployment: development script: - export CHANNEL_NAME=development - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel $CHANNEL_NAME
pull-requests: '**': - step: <<: *build-step - step: name: Deploy PR to Test Channel script: - CHANNEL_NAME="pr-$BITBUCKET_PR_ID" - 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 artifacts: - dist/**Multi-Environment Pipeline
Multi-Environment Pipelineのセクション複雑なデプロイシナリオのためのステージングとプロダクション環境:
# Multi-environment pipelineimage: node:22
pipelines: branches: main: - step: name: Build script: - npm ci - npm run test - npm run build artifacts: - dist/** - step: name: Deploy to Staging deployment: staging script: - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel staging - step: name: Deploy to Production deployment: production trigger: manual script: - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel production
develop: - step: name: Build and Deploy to Development script: - npm ci - npm run test - npm run build - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel development artifacts: - dist/**Branch-Based Deployment Strategy
Branch-Based Deployment Strategyのセクション自動的に異なるブランチを適切なチャンネルに展開します:
# Dynamic channel deploymentimage: node:22
definitions: scripts: - script: &determine-channel | if [ "$BITBUCKET_BRANCH" = "main" ]; then export CHANNEL_NAME="production" elif [ "$BITBUCKET_BRANCH" = "develop" ]; then export CHANNEL_NAME="staging" else export CHANNEL_NAME="development" fi echo "Deploying to channel: $CHANNEL_NAME"
pipelines: default: - step: name: Build and Deploy script: - npm ci - npm run test - npm run build - *determine-channel - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel $CHANNEL_NAME artifacts: - dist/**並列Pipeline実行
セクション「並列Pipeline実行」並列ステップでビルド時間を最適化します:
# Parallel execution pipelineimage: node:22
pipelines: branches: main: - parallel: - step: name: Run Tests script: - npm ci - npm run test - step: name: Lint Code script: - npm ci - npm run lint - step: name: Build Application script: - npm ci - npm run build artifacts: - dist/** - step: name: Deploy to Production deployment: production script: - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel productionセキュリティのベストプラクティス
セクション「セキュリティのベストプラクティス」リポジトリ変数
セクション「リポジトリ変数」- セキュア化された変数: API トークンは常にセキュア化されたものとしてマークする
- 環境変数: 必要に応じてデプロイ固有の変数を使用します
- アクセス制御: 認可されたチームメンバーのみにリポジトリへのアクセスを制限します
- トークンローテーション: 定期的に Capgo API トークンをローテーションします
デプロイメント環境
セクション “デプロイメント環境”デプロイメント環境をより安全に設定するには:
# Deployment with environment restrictionspipelines: branches: main: - step: name: Deploy to Production deployment: production trigger: manual script: - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel production監視と通知
セクション “監視と通知”Slackの統合
「Slackの統合」パイプラインにSlackの通知を追加:
# Pipeline with Slack notificationspipelines: branches: main: - step: name: Build and Deploy script: - npm ci - npm run test - npm run build - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel production after-script: - | if [ $BITBUCKET_EXIT_CODE -eq 0 ]; then curl -X POST -H 'Content-type: application/json' \ --data '{"text":"✅ Capgo deployment successful for '$BITBUCKET_BRANCH'"}' \ $SLACK_WEBHOOK_URL else curl -X POST -H 'Content-type: application/json' \ --data '{"text":"❌ Capgo deployment failed for '$BITBUCKET_BRANCH'"}' \ $SLACK_WEBHOOK_URL fiメール通知
「メール通知」Bitbucketの組み込み機能または外部サービスを使用してメール通知を設定:
# Email notification step- step: name: Send Notification script: - | curl -X POST \ -H "Content-Type: application/json" \ -d '{ "to": "team@yourcompany.com", "subject": "Capgo Deployment Status", "body": "Deployment of '$BITBUCKET_BRANCH' completed with status: '$BITBUCKET_EXIT_CODE'" }' \ $EMAIL_SERVICE_URL condition: result: [successful, failed]トラブルシューティング
「トラブルシューティング」一般的な問題
「一般的な問題」パイプラインが「Capgo CLI not found」というエラーで失敗します。
# Debug CLI installation- step: name: Debug CLI script: - npm install -g @capgo/cli - which capgo || echo "Capgo CLI not found" - npx @capgo/cli --version認証エラー:
# Verify token configuration- step: name: Debug Auth script: - | if [ -z "$CAPGO_TOKEN" ]; then echo "CAPGO_TOKEN is not set" exit 1 fi echo "Token length: ${#CAPGO_TOKEN}"ビルドアーティファクトが見つかりません:
# List build outputs- step: name: Debug Build script: - ls -la dist/ - find dist/ -type f -name "*.js" -o -name "*.html"デバッグパイプライン
「デバッグパイプライン」セクション問題を解決するためにデバッグ情報を追加します。
# Debug pipelinepipelines: branches: main: - step: name: Debug Information script: - echo "Branch: $BITBUCKET_BRANCH" - echo "Commit: $BITBUCKET_COMMIT" - echo "Build: $BITBUCKET_BUILD_NUMBER" - env | grep BITBUCKET_ | sort - step: name: Build and Deploy script: - npm ci - npm run test - npm run build - npm install -g @capgo/cli - npx @capgo/cli bundle upload --apikey $CAPGO_TOKEN --channel productionパイプライン検証
「パイプライン検証」セクション有効化 Pipelines の検証を設定して、構成エラーを検出します:
# Enable pipeline validationoptions: docker: true size: 2x
pipelines: branches: main: - step: name: Validate Pipeline script: - echo "Pipeline validation successful" - step: name: Build and Deploy script: # ... deployment steps- 短い UI ラベルまたはナビゲーションアイテム Native Build Builder Credit Next 次のステップ
- セクション 学び チャンネル
- Capgo リリースチャンネル機能名 Capgo Solutions マーケティング ページ / 自然のクラウドビルド製品ページ / 白ラベルページ (page solutions/white-label.astro)。短い UI ラベルまたはナビゲーションアイテム。メッセージキー `solutions_white_label_visual_cell2_value` (Solutions White Label Visual Cell2 Value)。 安全なデプロイメントのために
- 設定 更新の動作 更新の適用方法をカスタマイズするために
Capgoのデプロイメントを自動化し、モバイルアプリのユーザーに一貫した、信頼性の高い更新を保証することができます。
Bitbucket Pipelines Integrationから続けて
セクション「Bitbucket Pipelines Integrationから続けて」Bitbucket Pipelines Integrationを使用している場合 Bitbucket Pipelines Integrationを使用してCI/CDの自動化を計画している場合、__CAPGO_KEEP_0__ CI/CDと接続する __CAPGO_KEEP_0__ CI/CDの製品ワークフローに Capgo CI/CD Capgo Capgo 本機ビルド Capgo 本機ビルドの製品ワークフローに Capgo インテグレーション Capgo インテグレーション CI/CD インテグレーション __CAPGO_KEEP_0__ アクション インテグレーション GitHub アクション インテグレーションの実装詳細 for the implementation detail in GitHub Actions Integration.