Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Simple SFTP Deployment

Edison Chango June 12, 2022

Trying to execute a simple FTP deploy from bitbucket repo to FTP host

Pipelines YML at "https://bitbucket.org/echango/modx_pb_pdf_upload/deployments" keeps displaying error on lines by columns such as; "Expected a section but found sequence" or "Unexpected property 'deployment'" or "Unexpected property 'script'"

Kept on trying to execute code samples for FTP or SFTP deployments no luck using image provided by BITBUCKET

Even searched for thsi Post https://bitbucket.org/ian_buchanan/ftp-example/src/master/ which seems to be outdated but always appears on search results:
https://confluence.atlassian.com/search/?queryString=FTP%20with%20bitbucket

1 answer

1 vote
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 14, 2022

Hello @Edison Chango ,

Thank you for reaching out to Atlassian Community! 

The errors you reported are usually because of formatting issues in your YML file. You can use the below link to validate the YMLconfiguration for any error in the formatting before actually committing the bitbucket-pipelines.yml file in your repository : 

As for the SFTP deploy, I would suggest using the atlassian/sftp-deploy pipe, as it has most of the underlying code already done for you, and you just need to provide some variables. Please find below an example of using that pipe :

pipelines:
default:
- step:
name: 'Deploy with SFTP'
script:
- echo "This step will use atlassian/sftp-deploy pipe"
-
pipe: atlassian/sftp-deploy:0.5.11
   variables:
     USER: '<string>'
     SERVER: '<string>'
     REMOTE_PATH: '<string>'
     LOCAL_PATH: '<string>' #Optional

For more details about the atlassian/sftp-deploy pipe and how to configure the variables, please refer to the following documentation : 

Hope that helps! Let me know in case you have any questions or run into any issues.

Thank you @Edison Chango .

Kind regards,

Patrik S

Edison Chango June 17, 2022

This seems to be working.  Just one more detail.  Not sure f this is about the YM, but after all deployments were performed, there seems to be a lack of privileges or command to be run for getting files deleted.  Even simple txt files, after they are deleted from Source tree, removed from bitbucket, they do not get deleted from server.

 

This YML should be showcased, how can i promote this code, it comes very handy and should be accessible to anybody deploying small stuff?  Just need to get the successful deletion issue.

 

Any advise will be greatly appreciated.

Ed

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 20, 2022

Hello @Edison Chango ,

If I understand you correctly, you would like the files deleted from the source to also be deleted from the destination (your FTP server).

If that is the case, I'm afraid that SFTP does not support it, as it only allows you to transfer the files from one side to another, and not actually synch the folders.

In order to actually synch the files, and delete from the destination folder all the extraneous files that are not in the source folder, I would suggest using the atlassian/rsync-deploy pipe with the DELETE_FLAG : 

- pipe: atlassian/rsync-deploy:0.7.1
  variables:
    USER: '<string>'
    SERVER: '<string>'
    REMOTE_PATH: '<string>'
    LOCAL_PATH: '<string>'
DELETE_FLAG: 'true'

This will delete all the files from the destination folder that are not in the source folder.

More details about the available variables for that pipe can be found in its official documentation : 

 

Thank you, @Edison Chango !

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events