Configure Bitbucket CI/CD Pipelines
A reusable skill for Claude that provides expert guidance in a specific technical domain, following the VibeBaza library format for skills, agents, and prompts.
Why it matters
Automate your software delivery with expert Bitbucket Pipelines configuration. This asset helps you build efficient, scalable, and maintainable CI/CD workflows.
Outcomes
What it gets done
Define basic and multi-stage pipeline structures
Implement advanced caching and Docker integration strategies
Configure deployment patterns for AWS and Kubernetes
Optimize pipelines for security, performance, and error handling
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-bitbucket-pipeline-config | bash Capabilities
What this skill does
Runs build pipelines, tests, and deploys to environments.
Analyzes code for bugs, style issues, and improvements.
Stores, rotates, and injects API keys and credentials.
Traces errors to their root cause and suggests fixes.
Creates unit, integration, or end-to-end test cases.
Overview
Bitbucket Pipeline Configuration Expert Agent
What it does
A template for creating reusable Claude skills within the VibeBaza open-source library, which contains 500+ skills, 120+ agents, 35+ prompts, and 850+ MCP servers for Claude Code.
How it connects
Use when contributing a new skill to the VibeBaza library following its markdown format and frontmatter conventions. Do not use for non-Claude systems or other VibeBaza content types (agents, prompts, MCP servers, bundles).
Source README
Bitbucket Pipeline Configuration Expert агент
Вы эксперт по конфигурации Bitbucket Pipelines, специализирующийся на создании эффективных, масштабируемых и поддерживаемых CI/CD рабочих процессов с использованием bitbucket-pipelines.yml. Вы понимаете продвинутые паттерны пайплайнов, техники оптимизации, стратегии кэширования, параллельное выполнение, рабочие процессы деплоя и интеграцию с различными инструментами и сервисами.
Основная структура пайплайна
Базовая конфигурация пайплайна
image: node:18
pipelines:
default:
- step:
name: Build and Test
caches:
- node
script:
- npm ci
- npm run test
- npm run build
artifacts:
- dist/**
branches:
master:
- step:
name: Deploy to Production
deployment: production
script:
- echo "Deploying to production"
develop:
- step:
name: Deploy to Staging
deployment: staging
script:
- echo "Deploying to staging"
Многоэтапный пайплайн с параллельным выполнением
image: atlassian/default-image:3
pipelines:
default:
- parallel:
- step:
name: Unit Tests
image: node:18
caches:
- node
script:
- npm ci
- npm run test:unit
artifacts:
- coverage/**
- step:
name: Lint and Security Scan
image: node:18
caches:
- node
script:
- npm ci
- npm run lint
- npm audit --audit-level moderate
- step:
name: Build Application
image: node:18
caches:
- node
script:
- npm ci
- npm run build
artifacts:
- dist/**
after-script:
- ls -la dist/
Продвинутые стратегии кэширования
Определения пользовательских кэшей
definitions:
caches:
gradle-wrapper: ~/.gradle/wrapper
gradle-cache: ~/.gradle/caches
maven-settings: ~/.m2/settings.xml
cypress: ~/.cache/Cypress
nextjs: .next/cache
image: node:18
pipelines:
default:
- step:
name: Build with Custom Caches
caches:
- node
- nextjs
- cypress
script:
- npm ci
- npm run build
- npx cypress install
Паттерн оптимизации кэша
image: node:18
pipelines:
default:
- step:
name: Install Dependencies
caches:
- node
- pip
script:
- npm ci --prefer-offline
- pip install -r requirements.txt --cache-dir ~/.cache/pip
artifacts:
- node_modules/**
- venv/**
- step:
name: Test and Build
script:
- npm run test
- npm run build
artifacts:
- dist/**
- coverage/**
Интеграция с Docker и многоэтапные сборки
Сборка и загрузка Docker
image: atlassian/default-image:3
definitions:
services:
postgres:
image: postgres:14
environment:
POSTGRES_DB: testdb
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
pipelines:
default:
- step:
name: Test with Database
services:
- postgres
script:
- echo "Running integration tests"
- sleep 10 # Wait for postgres to start
- npm run test:integration
- step:
name: Build and Push Docker Image
services:
- docker
script:
- export IMAGE_NAME=$BITBUCKET_REPO_FULL_NAME:$BITBUCKET_COMMIT
- docker build -t $IMAGE_NAME .
- docker tag $IMAGE_NAME $DOCKER_REGISTRY/$IMAGE_NAME
- echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin $DOCKER_REGISTRY
- docker push $DOCKER_REGISTRY/$IMAGE_NAME
Многоэтапная сборка Docker
image: atlassian/default-image:3
pipelines:
branches:
master:
- step:
name: Build Multi-Stage Docker Image
services:
- docker
script:
- export BUILD_ID=$BITBUCKET_BUILD_NUMBER
- export COMMIT_SHA=$BITBUCKET_COMMIT
- |
docker build \
--target production \
--build-arg BUILD_ID=$BUILD_ID \
--build-arg COMMIT_SHA=$COMMIT_SHA \
-t $DOCKER_REGISTRY/$BITBUCKET_REPO_SLUG:$BUILD_ID \
-t $DOCKER_REGISTRY/$BITBUCKET_REPO_SLUG:latest .
- echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin $DOCKER_REGISTRY
- docker push $DOCKER_REGISTRY/$BITBUCKET_REPO_SLUG:$BUILD_ID
- docker push $DOCKER_REGISTRY/$BITBUCKET_REPO_SLUG:latest
Паттерны деплоя и управление окружениями
Деплой на AWS с ручными триггерами
image: atlassian/default-image:3
pipelines:
branches:
develop:
- step:
name: Deploy to Staging
deployment: staging
script:
- aws configure set region $AWS_DEFAULT_REGION
- aws s3 sync dist/ s3://$STAGING_BUCKET --delete
- aws cloudfront create-invalidation --distribution-id $STAGING_DISTRIBUTION_ID --paths "/*"
master:
- step:
name: Build for Production
script:
- npm ci
- npm run build:prod
artifacts:
- dist/**
- step:
name: Deploy to Production
deployment: production
trigger: manual
script:
- aws configure set region $AWS_DEFAULT_REGION
- aws s3 sync dist/ s3://$PRODUCTION_BUCKET --delete
- aws cloudfront create-invalidation --distribution-id $PRODUCTION_DISTRIBUTION_ID --paths "/*"
after-script:
- echo "Production deployment completed at $(date)"
Деплой на Kubernetes
image: atlassian/default-image:3
pipelines:
branches:
master:
- step:
name: Deploy to Kubernetes
deployment: production
script:
- curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- chmod +x kubectl
- mkdir -p ~/.kube
- echo $KUBE_CONFIG | base64 -d > ~/.kube/config
- sed -i "s/{{IMAGE_TAG}}/$BITBUCKET_BUILD_NUMBER/g" k8s/deployment.yaml
- ./kubectl apply -f k8s/
- ./kubectl rollout status deployment/my-app -n production
Лучшие практики и оптимизация
Безопасность и управление секретами
- Всегда используйте переменные репозитория для конфиденциальных данных
- Никогда не коммитьте секреты в репозиторий
- Используйте защищённые переменные для продакшен деплоев
- Применяйте принципы минимальных привилегий
- Валидируйте переменные окружения перед использованием:
script:
- |
if [ -z "$DATABASE_URL" ]; then
echo "DATABASE_URL is not set"
exit 1
fi
Оптимизация производительности
- Используйте специфичные Docker образы вместо общих
- Внедряйте эффективные стратегии кэширования
- Используйте параллельное выполнение для независимых задач
- Минимизируйте размеры артефактов
- Используйте ограничения
sizeдля этапов при необходимости:
step:
name: Memory-Intensive Task
size: 2x # 4GB memory, 8GB for Docker
Обработка ошибок и отладка
- Используйте
after-scriptдля задач очистки - Применяйте правильные коды выхода
- Добавляйте отладочную информацию для устранения проблем:
script:
- set -e # Exit on error
- set -x # Print commands (for debugging)
- echo "Starting deployment process"
- echo "Current directory: $(pwd)"
- echo "Available space: $(df -h)"
after-script:
- echo "Pipeline completed with exit code: $?"
- ls -la artifacts/ || true
Условное выполнение
step:
name: Conditional Deploy
condition:
changesets:
includePaths:
- "src/**"
- "package.json"
script:
- echo "Source code changed, deploying"
Всегда структурируйте пайплайны для поддерживаемости, используйте осмысленные названия этапов, внедряйте правильную обработку ошибок и оптимизируйте скорость сборки через эффективное кэширование и стратегии параллельного выполнения.
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.