FTP deployment using Bitbucket Pipeline

Are you fed up of deploying your website/application to a shared hosting like GoDaddy using FTP?
I can understand the pain because I was the one doing this for my applications because I did not have any other better option available. Following were the options I use to do.

- Select specific files and copy them to a specific folder. Deep hierarchies were a pain in the ass.
- Copy entire folder to the remote. Slow internet connection was sucking.
- Zip the folder, copy that to remote, go to cPanel and extract the folder there. Zip/Extract needed to create care.

Then I moved to dedicate servers where I had admin privileges. I installed Git and started to do deployments from my Bitbucket repo using bare repositories on the server. But this option has a security loophole.

I was searching for solutions to the above problems when I got to know about Bitbucket pipelines last year. I took out time to explore the option of using that for deployment and ended up with a solution which helped me automate my entire deployment.

Purpose of this post is to share that knowledge with everyone and help them take advantage of that Bitbucket Pipeline.

This tutorial will help you resolve the deployment problems over shared/dedicated hosting provided that you have at least FTP access to that. I will be using Bitbucket pipeline for that but you can leave a comment at the bottom if you want me to write some on any other option.

Requirement:
- FTP Access of the account
- Access to the code repository over Bitbucket
- A privilege of setting up Bitbucket Pipeline

Enabling and setting up Pipeline

Go to code repository in Bitbucket, locate the Pipeline link and go to the pipeline by clicking the link. Now select the language of your code.
Enable pipeline in repository


Put the below-mentioned code snippet in bitbucket-pipelines.yml. Don’t forget to change the YOUR_DOMIN variable.
Go to settings, locate the Environment Variables and set these 2 variables with their correct values. These variables are being used in bitbucket-pipelines.yml for connecting to the server for deployment purpose.

Make sure that the FTP user home directory is set to the directory you want your files to reside.


Now you should see “success” in pipelines table. This indicates that the code is successfully ready for deployment. Click the “success“ link


You can click the “Deploy” button to deploy it to your server.


After successful deployments, you should be able to track branches/commit successfully deployed to the server.


Enjoy deployments!

Comments