Odoo Bitbucket CI/CD Guide: Pipelines Setup
Set up complete Bitbucket Pipelines for your Odoo deployment. Auto-deploy on push, run automated tests, and manage staging environments with production-ready bitbucket-pipelines.yml configurations.
OEC.sh Supports Bitbucket Natively
Unlike Odoo.sh which only supports GitHub, OEC.sh provides native Bitbucket integration with direct webhooks - automatic deployments on every push.
1. Why Bitbucket for Odoo?
Bitbucket is a powerful Git platform from Atlassian, offering native CI/CD through Bitbucket Pipelines. For teams already using Jira or Confluence, Bitbucket provides seamless integration that tracks your Odoo development from ticket to deployment.
Atlassian Integration
Seamless integration with Jira, Confluence, and Trello for complete project management
Built-in Pipelines
Native CI/CD with easy YAML configuration and build minutes included
Pull Request Pipelines
Automatic builds on pull requests with merge checks and required builds
Free Private Repos
Unlimited private repositories for teams up to 5 users on free tier
Deployment Environments
Built-in deployment tracking with environment variables and history
IP Allowlisting
Static IP addresses for Pipelines - whitelist for secure server deployments
Note: Odoo.sh Doesn't Support Bitbucket
Odoo.sh only supports GitHub repositories. If your team uses Bitbucket, OEC.sh is the only Odoo hosting platform with native Bitbucket integration and automatic deployments.
2. Pipeline Architecture
A well-structured Bitbucket Pipeline for Odoo includes multiple steps that can run in parallel for efficiency. Here's the recommended architecture:
Pipeline Flow
Step 1: Lint
Run pylint-odoo and flake8 to catch code quality issues early.
Step 2: Test
Run Odoo unit tests with PostgreSQL service container.
Step 3: Build
Build Docker image and push to container registry.
Step 4: Deploy
Deploy to staging (automatic) or production (manual trigger).
3. bitbucket-pipelines.yml Examples
Here are production-ready pipeline configurations for different use cases. Copy the one that fits your needs and customize as needed.
A simple pipeline that runs linting and tests on every push:
image: python:3.10definitions: services: postgres: image: postgres:15 variables: POSTGRES_DB: odoo_test POSTGRES_USER: odoo POSTGRES_PASSWORD: odoopipelines: default: - parallel: - step: name: Lint caches: - pip script: - pip install pylint-odoo flake8 - flake8 addons/ --max-line-length=120 - pylint --load-plugins=pylint_odoo addons/ - step: name: Test services: - postgres caches: - pip script: - pip install -r requirements.txt - odoo --test-enable -d odoo_test --stop-after-init -i my_module after-script: - echo "Tests completed"4. Repository Variables
Configure these variables in Bitbucket: Repository Settings → Repository variables. Mark sensitive values as "Secured" to hide them in logs.
| Variable | Description | Secured |
|---|---|---|
| DOCKER_REGISTRY | Docker registry URL (e.g., docker.io/username) | No |
| DOCKER_USERNAME | Docker registry username | No |
| DOCKER_PASSWORD | Docker registry password or token | Yes |
| SSH_USER | SSH username for deployment | No |
| STAGING_SERVER | Staging server hostname/IP | No |
| PRODUCTION_SERVER | Production server hostname/IP | No |
SSH Key Setup
For SSH deployment, add your private key in Repository Settings → SSH keys. Bitbucket Pipelines automatically uses this for the ssh-run pipe.
5. Running Odoo Tests
Testing is crucial for Odoo deployments. Here's how to configure comprehensive test coverage in Bitbucket Pipelines:
Unit Test Configuration
- step: name: Run Odoo Tests services: - postgres caches: - pip script: # Install test dependencies - pip install coverage pytest-odoo # Run tests with coverage - | coverage run --source=addons \ $(which odoo) --test-enable \ -d odoo_test \ --db_host=localhost \ --db_user=odoo \ --db_password=odoo \ --stop-after-init \ -i $(ls addons/ | tr '\n' ',') # Generate coverage report - coverage report --fail-under=80 - coverage xml artifacts: - coverage.xmlTest Specific Modules
script: # Test only changed modules - | CHANGED_MODULES=$(git diff --name-only HEAD~1 | grep "^addons/" | cut -d'/' -f2 | sort -u | tr '\n' ',') if [ -n "$CHANGED_MODULES" ]; then odoo --test-enable -d odoo_test --stop-after-init -i $CHANGED_MODULES else echo "No module changes detected, skipping tests" fi6. Deployment Environments
Bitbucket Deployments provide environment tracking and deployment history. Configure environments in Repository Settings → Deployments.
Staging
- • Auto-deploys on push to staging branch
- • Uses staging-specific variables
- • No manual approval required
Production
- • Manual trigger required
- • Restricted to specific users
- • Environment-specific secrets
Environment-Specific Variables
Define deployment variables per environment in Bitbucket:
- step: name: Deploy to Staging deployment: staging # Uses staging environment variables script: - echo "Deploying to $SERVER_HOST" # From staging env - pipe: atlassian/ssh-run:0.4.1 variables: SSH_USER: $SSH_USER SERVER: $SERVER_HOST COMMAND: './deploy.sh'- step: name: Deploy to Production deployment: production # Uses production environment variables trigger: manual script: - echo "Deploying to $SERVER_HOST" # From production env - pipe: atlassian/ssh-run:0.4.1 variables: SSH_USER: $SSH_USER SERVER: $SERVER_HOST COMMAND: './deploy.sh'7. OEC.sh Bitbucket Integration
While Bitbucket Pipelines gives you full control over CI/CD, OEC.sh offers a simpler alternative with automatic deployments and zero pipeline configuration.
OEC.sh Automatic Deployment
Connect your Bitbucket repository in OEC.sh settings
OEC.sh creates webhooks automatically
Every push triggers automatic deployment
Branch-based environments (staging/production)
Bitbucket Pipelines
- • Full control over CI/CD
- • Custom test configurations
- • Build your own Docker images
- • Deploy anywhere via SSH
OEC.sh Integration
- • Zero configuration needed
- • Automatic Bitbucket webhooks
- • Built-in staging environments
- • One-click rollbacks
8. Best Practices
Use Caching Wisely
Cache pip dependencies and Docker layers to speed up builds significantly.
caches: - pip - dockerParallel Steps
Run lint and test in parallel to reduce pipeline duration.
- parallel: - step: name: Lint script: ... - step: name: Test script: ...Use YAML Anchors
Define reusable steps with YAML anchors to avoid duplication.
definitions: steps: - step: &test name: Test script: ...pipelines: branches: main: - step: *test # Reuse the test stepProtect Production Deployments
Always use manual triggers and restricted users for production deployments.
- step: name: Deploy Production deployment: production trigger: manual # Requires manual approval9. Frequently Asked Questions
Ready to Deploy Odoo from Bitbucket?
OEC.sh provides native Bitbucket integration with automatic deployments. Connect your repository and deploy in minutes - no pipeline configuration needed.