Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Hello,

This is a step of my yml file :

- step: &build-deploy-dev
name: 'Build + Deployment - DEV'
size: 2x
caches:
- node
deployment: test
script:
- npm run build-prod
- pipe: atlassian/sftp-deploy:0.5.4
variables:
USER: $USER
SERVER: $SERVER
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.

2 answers

2 accepted

0 votes
Answer accepted

The problem is solved by the ssh-run pipeline :

- pipe: atlassian/ssh-run:0.2.4
variables:
SSH_USER: $USER
SERVER: $SERVER
COMMAND: 'rm -rf /var/www/html/*'
DEBUG: 'false'
- pipe: atlassian/sftp-deploy:0.5.4
variables:
USER: $USER
SERVER: $SERVER
REMOTE_PATH: '/var/www/html/'
LOCAL_PATH: 'dist/*'
DEBUG: 'false'
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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

141 views 1 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you