Bitbucket Pipe for WP Engine Site Deployments
Tags:
Key Takeaways
Deploy WordPress code from Bitbucket to WP Engine using WP Engine Bitbucket Pipe. Options include deploying full site directory or sub-directory, custom rsync flags, and cache clearing. Utilizes WP Engine’s SSH Gateway for deployment.
Configuration requires saving private SSH Key to Bitbucket and public SSH Key to WP Engine. Set up bitbucket-pipelines.yml for deployment orchestration.
Create a bitbucket-pipelines.yml file in repo root for deployment configuration. Allows different workflows for various branches/environments.
Check out best practices for deploying with version control. Ensure files and directories are properly managed for deployment efficiency.
If you need to deploy WordPress® code from a Bitbucket repo to WP Engine, use our WP Engine Bitbucket Pipe.1 Deploy a full site directory or any sub-directory with the SRC_PATH and REMOTE_PATH options. Other options include custom rsync flags, or clearing cache.
This configuration uses WP Engine’s SSH Gateway, instead of WP Engine’s GitPush feature.
View the full guide on Bitbucket here.
Setup Instructions
The basic setup steps outlined below are:
- Generate an SSH key pair
- Add your SSH private key in Bitbucket
- Add your SSH public key in WP Engine
- Add a YAML config file
Generate an SSH Key Pair
Follow the steps in our SSH gateway article to Generate a new SSH key.
Add Your SSH Private Key in Bitbucket
- Add the Private key from the key pair you generated, to your Repository Variables or your Workspace variables.
- Bitbucket requires base64 encoding to store keys. This guide will outline how to encode your generated key in the proper format.
- Save the new secret “Name” as
WPE_SSHG_KEY_PRIVATE.
Add Your SSH Public Key in WP Engine
Add the Public key from the key pair you generated, to your SSH Keys in the WP Engine User Portal. This Guide will show you how.
Add a YAML Config File
- Create a
bitbucket-pipelines.ymlfile in the root of your repo locally. Copy and paste the configuration from below, replacing the value underbranches:and the value forWPE_ENV:- View YAML file examples below:
- Consult the Environment Variables & Secrets section below to see available options.
To deploy from another branch, simply create another yml file locally for that branch and replace the values for branches: and WPE_ENV: for that workflow.
After you’ve added you YAML file, Git push to your site’s Bitbucket repo. The pipeline will do the rest!
View your pipelines progress and logs by navigating to the “Pipelines” tab in your repository.
Example Bitbucket Pipeline Workflow
Copy and paste a configuration from below, replacing the value under branches: and the value for WPE_ENV:
Simple bitbucket-pipelines.yml
pipelines:
branches:
main:
- step:
name: Deploy to Production
script:
- pipe: wpengine/wpe-site-deploy:v2
variables:
WPE_SSHG_KEY_PRIVATE: $WPE_SSHG_KEY_PRIVATE
WPE_ENV: '<sitename>'
Extended sample bitbucket-pipelines.yml
pipelines:
branches:
main:
- step:
name: Deploy to Production
script:
- pipe: wpengine/wpe-site-deploy:v2
variables:
WPE_SSHG_KEY_PRIVATE: $WPE_SSHG_KEY_PRIVATE
WPE_ENV: '<sitename>'
staging:
- step:
name: Deploy to Staging
deployment: staging
script:
- pipe: wpengine/wpe-site-deploy:v2
variables:
WPE_SSHG_KEY_PRIVATE: $WPE_SSHG_KEY_PRIVATE
WPE_ENV: '<sitename>'
Environment Variables and Secrets
Required:
| Name | Type | Usage |
|---|---|---|
WPE_SSHG_KEY_PRIVATE | secrets | Base64 encoded Private SSH Key for the SSH Gateway and deployment. See below for SSH key usage. |
Deploy Options:
| Name | Type | Usage |
|---|---|---|
WPE_ENV | string | Insert the name of the WP Engine environment you want to deploy to. |
SRC_PATH | string | Optional path to specify a directory within the repo to deploy from. Ex. wp-content/themes/genesis-child-theme/ Defaults to root of repo filesystem as source. |
REMOTE_PATH | string | Optional path to specify a directory destination to deploy to. Ex. wp-content/themes/genesis-child-theme/ Defaults to WordPress root directory on WP Engine. |
FLAGS | string | Set optional rsync flags such as --delete or --exclude-from This pipe defaults to a non-destructive deploy using the flags -azvr --inplace --exclude=".*"Caution: Setting custom rsync flags replaces the default flags provided by this pipe. Consider also adding the -azvr flags as needed.-a preserves symbolic links, timestamps, user permissions and ownership.-z is for compression-v is for verbose output-r is for recursive directory scanning |
SCRIPT | string | Remote bash file to execute post-deploy. This can include WP_CLI commands for example. Path is relative to the WP root and file executes on remote. This file can be included in your repo, or be a persistent file that lives on your server. |
CACHE_CLEAR | bool | Optionally clear page and CDN cache post deploy. This takes a few seconds. Default is TRUE |
NEXT STEP: Check out our best practices for deploying when using version control


