Jake McMurchie saxophonist and Wordpress developer

Jake McMurchie

A basic CI/CD deployment from Bitbucket to Cloudways

Deploying code to servers is a perennial problem, especially for lone freelancers like me who don’t have nice Devops people to help. FTP (by which I mean SFTP, of course) is cumbersome and time-consuming. There are great services like DeployHQ but these come at a cost and I go through phases where I just don’t do that much deploying.

But I’ve found myself working on a handful of small projects and thought the time had come to get a basic CI/CD pipeline working (which is, I guess, exactly what DeployHQ is doing, or its equivalent anyway).

I found this very helpful video, but I’m going to go through the basics here since Bitbucket has updated a little since the video was published.

Initial context…

Cloudways settings…

Bitbucket settings…

Back in Cloudways…

Back to Bitbucket again…

Right, back in my code…

pipelines:
  branches:
    main:
      - step:
          name: "Deploy to production"
          script:
            - pipe: atlassian/sftp-deploy:0.10.0
              variables:
                USER: $SFTP_USERNAME
                SERVER: $SFTP_LOCATION
                REMOTE_PATH: "public_html/"
                LOCAL_PATH: "./"

Now, when you next >git push it’ll deploy automatically

Problems I encountered..

Getting the indenting / formatting of the .yml file was problematic. This was helpful:

https://bitbucket.org/product/pipelines/validator

I’ve also found I have to be careful about setting the path correctly.

More info…

https://bitbucket.org/product/features/pipelines/integrations?category=deployment&