push from bitbucket repository to shared hosting ftp server

20,991

Solution 1

You can use the new bitbucket tool, Pipelines! Configure a new pipeline file:

    image: samueldebruyn/debian-git
      pipelines:
      default:
        - step:
          script:
            - apt-get update
            - apt-get -qq install git-ftp
            - git ftp init --user $FTP_USERNAME --passwd $FTP_PASSWORD ftp://server/public_html/

Before you commit, create the environment variables $ FTP_USERNAME and $ FTP_PASSWORD in settings -> environment variables.

For the push edit the source code and change the "init" to "push" and commit to replace the file on your shared server.

For more information watch this video: https://www.youtube.com/watch?v=8HZhHtZebdw

Solution 2

This question is ages old. However, I am replying to the question in hopes of anyone else looking for a solution to this.

You can use the FTP Deployment PHP Script provided by BitBucket.

If you need FTPS explicit, in the functions.inc.php where you upload the above code, replace this line:

$conn_id = ftp_connect($ftp_host);

With the below:

// set up basic ssl connection
$conn_id = ftp_ssl_connect($ftp_host);

This should get you all set to use this script with explicit SSL-FTP connection instead of plain text FTP.

Share:
20,991
Ck Maurya
Author by

Ck Maurya

Updated on April 17, 2020

Comments

  • Ck Maurya
    Ck Maurya about 4 years

    I am using Bitbucket for managing my private repositories.
    I wish to deploy the files that are being updated on every commit to the ftp server.

    I google'd out and found many scripts, but couldn't succeeded with any of them. The ftp server is an shared hosting server which is accessed by Filezilla in FTP explicit connection mode.

    I don't want to use any third party online applications.

    Please guide me a walk through to the solution.

    I am trying to use this

    But which key must be entered in the deployment key of Bitbucket account? Private or Public?

  • AndyWarren
    AndyWarren about 7 years
    This worked for about a month and a half, then just stopped working. The Pipeline successfully finishes in Bitbucket, but its no longer copying any files over FTP. Been trying to figure it out for 2 days now. Any ideas?
  • Brian
    Brian about 7 years
    Hello friend, I have pipelines for a long time and I really did not pass, try to check that the FTP accesses in the environment variables are active, as long as the production server has not changed ip / domain
  • MaximOrlovsky
    MaximOrlovsky almost 7 years
    Git-FTP is the great solution for fast deploy.
  • Sudhir Kaushik
    Sudhir Kaushik almost 7 years
    Points to note in above answer: "$FTP_USERNAME" might raise a tooltip suggesting "The body has some invalid parameter". Remove special symbols and you are done.