The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

SFTP-Deploy Exclude Folder

KINKWILDE
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 23, 2019

This doesn't work

EXTRA_ARGS: '--exclude=node_modules/*'

sftp: unrecognized option: -

 

What is the correct way to exclude a folder from the atlassian/sftp-deploy:0.5.0 pipe?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 3, 2019

Hi KINKWILDE,

I'm not sure whether this will work, but you could try setting the GLOBIGNORE environment variable and then setting LOCAL_PATH using a glob pattern, eg:

- export GLOBIGNORE=node_modules
- pipe: atlassian/sftp-deploy:0.5.0
LOCAL_PATH='${BITBUCKET_CLONE_DIR}/*'

If that doesn't work, you could try creating a deployment directory first, containing exactly the files you want to upload. To make the copy easier, first create the directory outside your build directory.

- mkdir ~/deploy
- cp -R . ~/deploy
- mv ~/deploy .
- rm -rf deploy/node_modules
- pipe: atlassian/sftp-deploy:0.5.0
LOCAL_PATH='${BITBUCKET_CLONE_DIR}/deploy/*'

Or if the deployment command is the last command in your script (ie. you won't need node_modules again) then you could just delete it first:

- rm -rf node_modules
- pipe: atlassian/sft-deploy:0.5.0
LOCAL_PATH='${BITBUCKT_CLONE_DIR}/*'
4lJGhzpV
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 28, 2019

I had a similar problem like asked by user KINKWILD.
I wanted to exclude several files and folders from beeing uploaded by sftp-upload.
First of all the "bitbucket-pipelines.yml" file.


The first attempt - suggested by Steven Vacarella did not work in my case

...
- export GLOBIGNORE=node_modules
- pipe: atlassian/sftp-deploy:0.5.0
LOCAL_PATH='${BITBUCKET_CLONE_DIR}/*'
...

 

Adopting the second solution worked well - here is my example:

image: php:7.1.29

pipelines:
custom:
UploadToSFTP:
- step:
name: Deploy to SFTP Server
deployment: Test-1
script:
- mkdir ~/deploy
- cp -R . ~/deploy
- mv ~/deploy .
- rm -rf deploy/bitbucket-pipelines.yml
- pipe: atlassian/sftp-deploy:0.5.3
variables:
USER: <Your SFTP user name>
SERVER: <Your SFTP host>
LOCAL_PATH: '${BITBUCKET_CLONE_DIR}/deploy/*'
REMOTE_PATH: <Your SFTP remote path>
PASSWORD: <Your SFTP password> #if you are using pwd auth...

Note:
Without using deployment: ... my exampple from above was not not working!!

 

BR

Saul Baizman
July 4, 2020

I had the same question / issue: could I omit uploading bitbucket-pipelines.yml?

My solution is slightly simpler than 4lJGhzpV's: I just added the appropriate rm command above the pipe. No need to create a separate directory and so forth.

image: atlassian/default-image:2

pipelines:
default:
- step:
name: Publish
deployment: production
script:
- rm -rf bitbucket-pipelines.yml
- pipe: atlassian/sftp-deploy:0.5.6
variables:
USER: $DREAMHOST_USER
SERVER: $DREAMHOST_HOST
REMOTE_PATH: $DREAMHOST_REMOTE_PATH
LOCAL_PATH: $LOCAL_PATH
PASSWORD: $DREAMHOST_PASSWORD

I was worried deleting the pipeline would be problematic, but this didn't seem to have any ill effects.

TAGS
AUG Leaders

Atlassian Community Events