Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy only changed files via atlassian/ftp-deploy:0.2.0 in Bitbucket Pipelines?

I am new to BitBucket pipelines, as I used Webhook for deploying my changes to FTP.

I have set reccommended atlassian/ftp-deploy:0.2.0 pipeline and it works fine, BUT I would like to set that ONLY CHANGED files are taken and sent to FTP.

image: node:10.15.3

pipelines:
  default:
    - step:
        name: FTP Deploy
        script: # Modify the commands below to build your repository.
          - pipe: atlassian/ftp-deploy:0.2.0
            variables:
              USER: 'myFTPusername'
              PASSWORD: 'myFTPpass'
              SERVER: 'myFTPserver'
              REMOTE_PATH: 'myFTPpath'
    - step:
        name: Deploy message
        deployment: test
        script:
          - echo "Deploying to main environment"

Any help how to set this up so it sends only changed files to FTP?

Expected output is code for bitbucket-pipelines.yml

like image 696
snorbik Avatar asked Jul 16 '19 13:07

snorbik


People also ask

Which is a deployment model of bitbucket?

Bitbucket Deployments is built for teams doing continuous delivery, which generally means deploying to SaaS/web environments at least once per week, and preferably much more often. We believe this is the future of software development, and want to help as many teams get there as possible.


1 Answers

atlassian/ftp-deploy:0.3.6 delete all files, I found this image wagnerstephan/bitbucket-git-ftp:latest it's very useful, light and runs well and updates only changed files.

The first pipeline will run with an error, so select the commit then run again the pipeline with the init option selected.

image: wagnerstephan/bitbucket-git-ftp:latest

pipelines:
  custom:
    init:
    - step:
        script:
          - git reset --hard
          - git ftp init -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST/
    deploy:
    - step:
        script:
          - git reset --hard
          - git ftp push -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST/--all
  branches:
    develop:
      - step:
          name: Deploy Develop
          deployment: develop
          script:
           - git reset --hard
           - git ftp push -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST/
    master:
    - step:
        name: Deploy production
        deployment: production
        script:
          - git reset --hard
          - git ftp push -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST/

NOTE: check the name of the environments in the Bitbucket repository.

like image 119
e-israel Avatar answered Sep 29 '22 18:09

e-israel