CI/CD setup for websites via Bitbucket Pipelines
We often encounter projects where deployments are done manually via FTP — leading to errors and lost time. In one Symfony project, manual deployment took 40 minutes and every fifth release had to be rolled back due to a forgotten migration. After implementing Bitbucket Pipelines, the process was reduced to 8 minutes, and failures dropped to zero. Moreover, the team stopped spending time coordinating releases — the pipeline performs all checks automatically.
We configure CI/CD in Bitbucket Pipelines so that each build runs static analysis, unit tests, and integration checks, then autonomously deploys to the server. This not only speeds up releases but also eliminates human error: forgotten migrations, incorrect configs, missing dependencies.
Problems we solve
- Different environments: staging and production often have different configs. Pipelines allows setting distinct variables for each deployment environment.
- Long manual deployments: one click and the build with tests starts automatically. No waiting for a developer.
-
Configuration errors: frequently mixed up SSH keys or forgotten dependencies. We define everything in the YAML, and the
after-scriptnotifies about issues. - Lack of tests: many projects lack automated checks. We integrate static analysis, unit tests, and linters directly into the pipeline. For example, for a React 18 TypeScript frontend project we added ESLint, Jest, and Playwright — the pipeline immediately catches regressions.
How CI/CD works in Bitbucket Pipelines
Bitbucket Pipelines is built into the repository — no separate CI server needed. You describe steps in a bitbucket-pipelines.yml file, and Bitbucket runs them inside a Docker container. Compared to GitLab CI, setup takes roughly half the time: no need to manage runners. You get 50 free build minutes per month; paid plans remove limits (starting at $10/month).
Setup process
- Repository audit: determine the tech stack, tests, and environments.
-
Create
bitbucket-pipelines.yml: write steps for build, test, and deploy. - Configure variables: set secrets (SSH keys, tokens) in Repository Settings.
- Configure environments: create staging and production with manual approval.
- Testing: run the pipeline on a test branch.
- Documentation: describe the launch and rollback process.
Example: basic configuration for Node.js and deploy via rsync
image: node:20-alpine
pipelines:
branches:
main:
- step:
name: Test
caches:
- node
script:
- npm ci
- npm test
- step:
name: Build
caches:
- node
script:
- npm ci
- npm run build
artifacts:
- dist/**
- step:
name: Deploy
deployment: production
script:
- apt-get update && apt-get install -y openssh-client rsync
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- rsync -avz --delete dist/ deploy@$DEPLOY_HOST:/var/www/mysite/
pull-requests:
'**':
- step:
name: Test PR
script:
- npm ci
- npm test
- npm run lint
Advanced features
Environment variables and artifacts
Variables are stored in Repository Settings → Repository variables. The secured flag hides the value from logs. Artifacts pass files between steps, e.g., dist/ and .env.production. They are retained for 14 days, enough for debugging. Comparison of settings for environments:
| Parameter | Staging | Production |
|---|---|---|
| Variable DB_HOST | staging.db.example.com | prod.db.example.com |
| Dev build | enabled | disabled |
Parallel steps and manual trigger
Parallel steps speed up the pipeline — tests, linter, and E2E run simultaneously. For production, we use trigger: manual so deployment only happens after approval.
Custom pipeline for rollback
Example rollback pipeline
pipelines:
custom:
rollback:
- variables:
- name: RELEASE_TAG
default: 'v1.0.0'
- step:
name: Rollback to tag
script:
- git fetch --tags
- git checkout $RELEASE_TAG
- npm ci && npm run build
- ./deploy.sh production
Run via Bitbucket UI: Pipeline → Run pipeline → select rollback → specify the tag.
Docker build and PHP
# Docker build
image: atlassian/default-image:4
pipelines:
branches:
main:
- step:
services:
- docker
script:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- docker build -t myrepo/mysite:$BITBUCKET_COMMIT .
- docker push myrepo/mysite:$BITBUCKET_COMMIT
- docker tag ... && docker push ...
# PHP (Laravel/Symfony)
image: php:8.3-cli
definitions:
caches:
composer: vendor
pipelines:
branches:
main:
- step:
caches:
- composer
script:
- apt-get update && apt-get install -y unzip libpq-dev
- docker-php-ext-install pdo_pgsql
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install --no-dev --optimize-autoloader
- php artisan config:cache
- php artisan migrate --force
Notifications
- step:
script:
- npm run build
after-script:
- |
if [ $BITBUCKET_EXIT_CODE -ne 0 ]; then
curl -s -X POST $SLACK_WEBHOOK \
-H 'Content-type: application/json' \
-d '{"text":"Build failed: '"'$BITBUCKET_REPO_FULL_NAME'"'"}'
fi
Typical timeline and what's included
| Stage | Duration |
|---|---|
| Repository audit and YAML creation | 1–4 hours |
| Variable and SSH key setup | 1–2 hours |
| Test and build configuration | 2–6 hours |
| Deploy configuration (staging/production) | 2–4 hours |
| Pipeline testing | 1–2 hours |
| Documentation and training | 1–2 hours |
Total: from 1 to 3 days depending on complexity.
What's included: ready bitbucket-pipelines.yml with comments, environment variable setup (including secrets), optional Jira integration, instructions for launching and rolling back, and a week of consultation and support after launch.
Why automate deployment?
Bitbucket Pipelines is built into the Atlassian ecosystem and integrates with Jira — commits and builds appear directly in issues. Setup is simpler than GitLab CI (no runners needed), and paid plans start at $10/month. Savings on a dedicated DevOps engineer: up to $500 per month.
Ready to automate your deployment?
Get a consultation on setting up CI/CD for your project. We'll assess your repository and prepare a pipeline in 1–3 days. With 5+ years of experience configuring CI/CD for dozens of sites, we guarantee stable builds. Order deployment automation today.







