Automating WordPress Deployment with Bitbucket: Dev & Live Environments Made Easy
Managing a WordPress project across multiple environments—especially when working with a team—can become complex and error-prone. That’s why automating deployment using Bitbucket, and integrating a workflow for Dev and Live servers, can save hours of manual work and reduce risk.
In this blog post, we’ll walk you through a complete setup of automated WordPress deployment using Bitbucket for two environments: Dev and Live, with the goal of:
🧩 Technologies Used
🗂️ Repository Structure
Before starting, make sure your WordPress project is in a Git-friendly structure. Recommended setup:
/my-wordpress-project
├── wp-content/
│ ├── themes/
│ └── plugins/
├── .env
├── wp-config.php
├── bitbucket-pipelines.yml
Avoid committing core WordPress files unless you're managing it as a full Git repo. Ideally, version-control only wp-content, custom plugins, and themes.
🔄 Git Branching Strategy
A clean branching strategy is crucial:
🛠️ Step-by-Step Setup
Step 1: Enable Bitbucket Pipelines
Step 2: Prepare Servers
✅ Dev Server (dev.example.com)
✅ Live Server (example.com)
Step 3: Add Environment Variables in Bitbucket
Go to Repository Settings > Repository Variables and add:
For both servers:
Optional:
Recommended by LinkedIn
Step 4: Setup bitbucket-pipelines.yml
image: atlassian/default-image:latest
pipelines:
branches:
dev:
- step:
name: Deploy to Dev Server
script:
- pipe: atlassian/ftp-deploy:0.4.0
variables:
USER: $FTP_DEV_USER
PASSWORD: $FTP_DEV_PASS
SERVER: $FTP_DEV_HOST
REMOTE_PATH: $FTP_DEV_PATH
LOCAL_PATH: "wp-content"
main:
- step:
name: Deploy to Live Server
script:
- pipe: atlassian/ftp-deploy:0.4.0
variables:
USER: $FTP_LIVE_USER
PASSWORD: $FTP_LIVE_PASS
SERVER: $FTP_LIVE_HOST
REMOTE_PATH: $FTP_LIVE_PATH
LOCAL_PATH: "wp-content"
🧠 Environment-Specific wp-config.php
Use conditional logic to manage environment-specific settings.
<?php
$env = getenv('WP_ENV') ?: 'production';
if ($env === 'development') {
define('WP_DEBUG', true);
define('DB_NAME', 'dev_db');
// other dev config
} else {
define('WP_DEBUG', false);
define('DB_NAME', 'live_db');
// other live config
}
Set WP_ENV in .htaccess or .env file per server.
🚧 Handling Database and Media
Code deployment is easy, but database and media uploads can be tricky.
Options:
🔒 Best Practices
🧪 Optional: Add Slack or Email Notifications
Extend pipelines:
wp-config.php
.env
node_modules/
vendor/
🧾 Summary
StageActionAutomationCode PushPush to devDeploy to DevQA ApprovalMerge dev → mainDeploy to LiveDeploymentVia Bitbucket PipelinesFTP or SSHDB & MediaManual or semi-autoUse migration tools
🎯 Final Thoughts
With this setup:
Automation not only speeds things up but also enforces discipline in how updates move from local development to production.
If you want this setup customized with GitHub, Jenkins, GitLab, or Cloud-based deployments (e.g., WP Engine, Kinsta) — feel free to drop a comment or message me!
Helpful insight, Rizwan
Very informative