메뉴로 이동

Bitbucket Pipelines 통합

Bitbucket Pipelines와 함께 Capgo Live Updates를 통합하여 앱 업데이트를 자동으로 배포할 수 있습니다. code 변경 사항을 푸시할 때마다.

Bitbucket Pipelines 통합을 설정하기 전에 다음을 확인하세요:

  • Bitbucket 계정과 저장소
  • Capgo 계정과 앱이 구성된
  • Node.js와 npm/yarn이 프로젝트에 구성된

Bitbucket Pipelines 설정

제목 ‘Bitbucket Pipelines 설정’

1단계: 저장소 변수를 구성

Step 1: Repository 변수 설정하기

먼저 Bitbucket 저장소에서 필요한 변수를 설정하세요:

  1. Bitbucket 저장소로 이동하세요
  2. 로 가세요 저장소 설정파이프라인저장소 변수
  3. 다음 변수를 추가하세요:
변수 이름암호화
CAPGO_TOKENCapgo API 토큰✅ Yes

메인 branch에 푸시될 때마다 프로덕션으로 배포되는 기본 설정입니다.

# bitbucket-pipelines.yml - Simple Configuration
image: 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 deployment
pipelines:
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/**

If you’re using Capgo’s encryption feature, you’ll need to securely store your private key in your CI/CD environment.

After setting up encryption keys locally, add your private key to Bitbucket variables:

Terminal 창
# Display your private key content (copy this output)
cat .capgo_key_v2

Bitbucket 저장소 변수에 이 내용을 추가하세요 (비밀번호로 마크): CAPGO_PRIVATE_KEY Copy to clipboard

# 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

다중 채널 구성

다중 채널 구성

다중 채널 구성에 대한 자세한 정보는 Channels 문서를 참조하세요 다중 환경 및 PR 배포를 위한 완전한 구성:.

클립보드에 복사하기

# bitbucket-pipelines.yml - Advanced Multi-Channel Configuration
image: 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 pipeline
image: 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 deployment
image: 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/**

클립보드 복사

# Parallel execution pipeline
image: 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

안전성 최적화 방법

안전성 최적화 방법 섹션

저장소 변수

저장소 변수 섹션
  1. 보안 변수API 토큰은 항상 보안 처리합니다.
  2. 환경 변수배포에 따라 필요한 경우 배포별 변수를 사용합니다.
  3. 접근 제어권한이 있는 팀 멤버만 저장소에 접근하도록 제한합니다.
  4. 토큰 회전Capgo API 토큰을 정기적으로 회전합니다.

보안을 위해 배포 환경을 구성하세요:

# Deployment with environment restrictions
pipelines:
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 with Slack notifications
pipelines:
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

이메일 알림 섹션

클립보드에 복사

Configure 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'이 발견되지 않아 실패합니다.

# 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 Pipeline

Debug Pipeline

Add debugging information to troubleshoot issues:

# Debug pipeline
pipelines:
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

Pipeline Validation

Pipeline Validation

Enable pipeline validation to catch configuration errors:

# Enable pipeline validation
options:
docker: true
size: 2x
pipelines:
branches:
main:
- step:
name: Validate Pipeline
script:
- echo "Pipeline validation successful"
- step:
name: Build and Deploy
script:
# ... deployment steps

Next Steps

Next Steps

Capgo 배포를 자동화하고, 안정적이고 신뢰할 수 있는 업데이트를 사용자에게 제공하세요.

__CAPGO_KEEP_0__ 배포를 자동화하고, 안정적이고 신뢰할 수 있는 업데이트를 사용자에게 제공하세요.

Bitbucket Pipelines 통합에서 계속하기

Bitbucket Pipelines 통합을 사용 중이라면 Bitbucket Pipelines 통합 CI/CD 자동화 계획을 위해 Bitbucket Pipelines 통합을 연결하세요. Capgo CI/CD Capgo CI/CD에서 제품 워크플로우를 위해 Capgo 네이티브 빌드 Capgo 네이티브 빌드에서 제품 워크플로우를 위해 Capgo 통합 Capgo 통합에서 제품 워크플로우를 위해 CI/CD 통합 CI/CD 통합 구현 세부 정보 GitHub 액션 통합 GitHub 액션 통합 구현 세부 사항을 위해.