CraftedTemplate
Blog How to Automate Deployment Pipelines with Bitbucket Pipelines (Complete Guide)

How to Automate Deployment Pipelines with Bitbucket Pipelines (Complete Guide)

11/1/2025 • Festus Ayomike
How to Automate Deployment Pipelines with Bitbucket Pipelines (Complete Guide)

Bitbucket isn’t just for code hosting — it also has a built-in CI/CD system called Bitbucket Pipelines.

If your repositories are hosted on Bitbucket, this tool can automatically build, test, and deploy your app whenever you push new commits — similar to GitHub Actions or GitLab CI/CD.

In this tutorial, you’ll learn how to set up Bitbucket Pipelines to automate your website deployment step by step.

See Also: How to Deploy Containerized Apps with Docker Compose (Step-by-Step Guide)

What Is Bitbucket Pipelines?

Bitbucket Pipelines lets you:

  • Define automated workflows using a bitbucket-pipelines.yml file.
  • Run builds and tests in a cloud container environment.
  • Deploy to hosting providers, servers, or cloud platforms.

It’s ideal for teams already using Atlassian tools like Jira or Trello.

Step 1: Enable Pipelines

  1. Go to your Bitbucket repository.
  2. Navigate to Repository Settings → Pipelines → Enable Pipelines.

Bitbucket will now look for a bitbucket-pipelines.yml file in your project.

Step 2: Create the Pipeline File

In your project root, add bitbucket-pipelines.yml:

Code · yaml
image: node:18

pipelines:
  branches:
    main:
      - step:
          name: Build and Deploy
          caches:
            - node
          script:
            - npm ci
            - npm run build
            - pipe: atlassian/ftp-deploy:0.3.6
              variables:
                USER: $FTP_USER
                PASSWORD: $FTP_PASS
                SERVER: ftp.yourhost.com
                REMOTE_PATH: /public_html

Explanation:

  • Uses Node.js to build your site.
  • Deploys via FTP to your hosting provider automatically.
  • Credentials are stored securely as repository variables.

Step 3: Add Environment Variables

Go to Repository Settings → Pipelines → Repository Variables and add:

  • FTP_USER
  • FTP_PASS

If you’re using another host (like AWS or Netlify), you can add their API tokens here instead.

Step 4: Add a Custom Deployment (Example: AWS S3)

Here’s how to deploy a static site to AWS S3:

Code · yaml
image: python:3.10

pipelines:
  branches:
    main:
      - step:
          name: Deploy to S3
          script:
            - pip install awscli
            - aws s3 sync ./build s3://mybucket --delete
          services:
            - docker

You’ll also need AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) added as environment variables.

Step 5: Test and Monitor

Push your changes:

Code · batchfile
git add bitbucket-pipelines.yml
git commit -m "Add Bitbucket pipeline"
git push

Go to Bitbucket → Pipelines tab to view logs, status, and deployment results in real-time.

Bonus: Add Multiple Environments

You can define multiple environments for staging and production:

Code · yaml
pipelines:
  branches:
    staging:
      - step:
          name: Deploy to Staging
          script:
            - npm run build:staging
    main:
      - step:
          name: Deploy to Production
          script:
            - npm run build && npm run deploy

Conclusion

Bitbucket Pipelines is an excellent CI/CD option for teams already working in the Atlassian ecosystem.

With just one YAML file, you can automatically build, test, and deploy your apps every time you push new changes — no extra servers required.

Coming up next in Hosting Academy: you’ll learn how to host a website on an Nginx VPS and configure SSL with Certbot for production-ready performance.