Bitbucket Pipelines 통합
이 플러그인의 설치 단계와 전체 마크다운 가이드가 포함된 설정 프롬프트를 복사하세요.
code 변경 사항을 푸시할 때마다 자동으로 앱 업데이트를 배포하는 Bitbucket Pipelines과 Capgo Live Updates를 통합하세요. 이 가이드는 자동 빌드, 테스트 및 배포 워크플로우를 설정하는 방법을 다룹니다.
사전 요구 사항
제목 ‘사전 요구 사항’Bitbucket Pipelines 통합을 설정하기 전에 다음을 확인하세요:
- Bitbucket 계정과 저장소
- Capgo 계정과 앱이 구성된 Capgo
- Node.js 및 npm/yarn이 프로젝트에 구성된 경우
Bitbucket Pipelines 설정
Bitbucket Pipelines 설정Step 1: 저장소 변수를 설정하십시오
Step 1: 저장소 변수를 설정하십시오먼저, Bitbucket 저장소에서 필요한 변수를 설정하십시오:
- Bitbucket 저장소로 이동하십시오
- 로 이동하십시오 저장소 설정 → 파이프라인 → 저장소 변수
- 다음 변수를 추가하십시오:
| 변수 이름 | 값 | 암호화 |
|---|---|---|
CAPGO_TOKEN | Capgo API 토큰 | ✅ Yes |
Section titled “Simple”
메인 branch에 푸시할 때마다 프로덕션으로 배포되는 기본 설정입니다.__CAPGO_KEEP_0__ __CAPGO_KEEP_1__ 토큰을 클립보드에 복사합니다.
# 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/**고급
고급 섹션기능 branch 배포
기능 branch 배포 섹션기능 branch를 테스트 채널에 배포하여 검토 및 테스트를 위해:
# 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_KEEP_0__의 암호화 기능을 사용 중이라면 Capgo’s encryption feature암호화 키를 설정한 후
Bitbucket 변수에 개인 키를 추가하세요: 터미널 창 복사
# Display your private key content (copy this output)cat .capgo_key_v2Bitbucket 저장소 변수에 다음 내용을 추가하세요 (비밀으로 표시) 후 pipeline에서 사용하세요: CAPGO_PRIVATE_KEY 복사
# 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 production다중 채널 구성
다중 채널 구성에 대한 자세한 정보는채널 문서를 참조하세요. 다중 환경 및 pull request 배포를 위한 완전한 구성:.
__CAPGO_KEEP_0__
# 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/**다중 환경 PIPELINE
다중 환경 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 배포 전략
Branch-Based 배포 전략 섹션다른 Branch를 적절한 채널로 자동 배포할 수 있습니다.
# 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 실행
병렬 단계를 사용하여 빌드 시간을 최적화할 수 있습니다.__CAPGO_KEEP_0__
# 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모니터링 및 알림
모니터링 및 알림슬랙 통합
슬랙 통합pipeline에 슬랙 알림을 추가하세요:
# 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]문제 해결
문제 해결 섹션일반적인 문제
일반적인 문제 섹션pipeline이 “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"디버그 PIPELINE
디버그 PIPE라인 섹션문제를 해결하기 위해 디버깅 정보를 추가하세요:
# 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 productionPIPELINE VALIDATION
PIPELINE VALIDATION 섹션구성 오류를 잡기 위해 PIPELINE VALIDATION을 활성화하세요:
# 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다음 단계
다음 단계 섹션- 학습 채널 __CAPGO_KEEP_0__를 관리하는 다양한 배포 환경
- 탐색 고급 배포 시나리오를위한 사용자 정의 저장소 설정
- 보안 배포를위한 암호화 설정 업데이트 동작을 커스터마이즈하여 업데이트가 적용되는 방식을 조정
- Bitbucket Pipelines 통합을 통해 __CAPGO_KEEP_0__ 배포를 자동화하고 모바일 앱 사용자에게 일관된, 신뢰할 수 있는 업데이트를 보장할 수 있습니다. Bitbucket Pipelines 통합을 통해 __CAPGO_KEEP_0__ 배포를 자동화하고 모바일 앱 사용자에게 일관된, 신뢰할 수 있는 업데이트를 보장할 수 있습니다. Bitbucket Pipelines 통합을 통해 __CAPGO_KEEP_0__ 배포를 자동화하고 모바일 앱 사용자에게 일관된, 신뢰할 수 있는 업데이트를 보장할 수 있습니다.
Bitbucket Pipelines 통합을 통해 Capgo 배포를 자동화하고 모바일 앱 사용자에게 일관된, 신뢰할 수 있는 업데이트를 보장할 수 있습니다.