Hi,
With a sftp script like the following one, I get a deployment faillure/
- pipe: atlassian/sftp-deploy:0.5.8
variables:
DEBUG: 'true'
USER: 'wwwuser'
SERVER: '<servername>'
REMOTE_PATH: '<path>'
LOCAL_PATH: '${BITBUCKET_CLONE_DIR}/<deploy stuff>'
EXTRA_ARGS: "--exclude='.*'"
In the logs this is the sftp command that's generated. The empy '-' is the cause of the problem, but I can't find how to remove it.
sftp -b - -rp -v '--exclude='\''.*'\''' wwwuser@<servername>:<path>
Hi @Rob Buijs
Thank you for your question!
Found this discussion and I'll try to help.
1. The empty '-' in the SFTP command is not an issue, pipe use it as part of -b option:
man sftp
-b batchfile
Batch mode reads a series of commands from an input batchfile instead of stdin. Since it lacks user interaction it should be used in conjunction
with non-interactive authentication to obviate the need to enter a password at connection time (see sshd(8) and ssh-keygen(1) for details).A batchfile of ‘-’ may be used to indicate standard input. sftp will abort if any of the following commands fail: get, put, reget, reput, rename,
ln, rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp, lpwd, df, symlink, and lmkdir.Termination on error can be suppressed on a command by command basis by prefixing the command with a ‘-’ character (for example, -rm /tmp/blah*).
Echo of the command may be suppressed by prefixing the command with a ‘@’ character. These two prefixes may be combined in any order, for example
-@ls /bsd.
2. The root cause for the error
sftp: unrecognized option: -
is
EXTRA_ARGS: "--exclude='.*'"
that you try to pass into sftp, but sftp supports only:
sftp
usage: sftp [-46AaCfNpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
[-D sftp_server_path] [-F ssh_config] [-i identity_file]
[-J destination] [-l limit] [-o ssh_option] [-P port]
[-R num_requests] [-S program] [-s subsystem | sftp_server]
destination
So, to have ability to exclude files you could use an alternative pipe:
Example with an EXTRA_ARGS to exclude all files with '.txt' extension from deploy.
script: - pipe: atlassian/rsync-deploy:0.10.1 variables: USER: 'ec2-user' SERVER: '127.0.0.1' REMOTE_PATH: '/var/www/build/' LOCAL_PATH: 'build' DEBUG: 'true' EXTRA_ARGS: '--exclude=*.txt'
CC: @Beau Liddell @Ankit Gupta
Best regards,
Oleksandr Kyrdan
I have a ssh key for that account, not a password. I tried with a fake password, just to see what happened:
+ echo -e '\e[37mDEBUG: Executing echo "mput /opt/atlassian/pipelines/agent/build/avada-child-theme" | sshpass -p blieb sftp -o PubkeyAuthentication=no -rp -v --exclude='\''.*'\'' wwwuser@<server>:<path>\e[0m'
sftp: unrecognized option: -
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Rob Buijswere you able to get this resolved? I'm facing the exact same issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rob,
You can try setting the PASSWORD variable for the pipe.
As per the code: https://bitbucket.org/atlassian/sftp-deploy/src/5166e989d76963957c12e2eb2c861d9cf6ba434d/pipe.sh#lines-100
In case the $PASSWORD var isn't defined, the other sftp cmd is triggered (which leads to error for you). Its possible the cmd doesn't work with PASSWORD based servers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.