Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to remove files from a previous deployment with sftp-deploy pipeline



This is a step of my yml file :

- step: &build-deploy-dev
name: 'Build + Deployment - DEV'
size: 2x
- node
deployment: test
- npm run build-prod
- pipe: atlassian/sftp-deploy:0.5.4
REMOTE_PATH: '/var/www/html/'
LOCAL_PATH: 'dist/*'
EXTRA_ARGS: 'rm *'

I'm trying to delete the files previously deployed on the remote server before copying the new ones but the EXTRA_ARGS command doesn't work :/.

Because the build-prod command generate files like : main.js?qd87dz8z25zd4
The number at the end changes at each build, so i need to clean up the remote folder in order to prevent to have a lot of main.js?XXXXXX outdated.

3 answers

2 accepted

0 votes
Answer accepted

The downside of using a rm here is that there's a short time when your web site isn't available. Also, if the later deployment phase stops (e.g. due to failure) your web site is down. Another approach that is worth considering is this:

  1. Deploy to a folder location which has directories within it which includes the build or deployment number (e.g. www/website/v1 , www/website/v2 www/website/v3)
  2. Have a symbolic link that points to the current release (e.g.  www/website/latest -> www/website/v3)
  3. Once the new release (www/website/v4) is deployed successfully switch the symbolic link (www/website/latest -> www/website/v4)
  4. Delete all releases automatically that are older than X and are not the symbolic link.


You can extend this to also have a simple rollback by having an 'old' link. To rollback, a script would move all the symbolic links back. Old can't really change though and you need to think through changing the links there.

0 votes
Answer accepted

The problem is solved by the ssh-run pipeline :

- pipe: atlassian/ssh-run:0.2.4
COMMAND: 'rm -rf /var/www/html/*'
DEBUG: 'false'
- pipe: atlassian/sftp-deploy:0.5.4
REMOTE_PATH: '/var/www/html/'
LOCAL_PATH: 'dist/*'
DEBUG: 'false'

Sorry for refloating this old post...

I'm confronted with the same situation and would really appreciate a more detailed "instructions".

The symlink to the current deployment: can I update automatically as part of my pipeline in the last step?

The version to which to redirect the symlink: can that be updated automatically with some random generator?

For removing all folders from old deployments: should I set up a linux job for that? How do I exclude the folder that is currently being referenced in the symlink?


Thanks much!


Suggest an answer

Log in or Sign up to answer

Atlassian Community Events