While trying to use .gitlab-ci.yml
to automatically deploy my theme to my production server, I receive a error:
The command executed: using a ubuntu:16.04 image
$ apt update -y && apt install openssh-client sshpass rsync -y
$ rsync -avh --progress --delete --rsh="sshpass -p $STAGE_FTP_PASS ssh -o StrictHostKeyChecking=no " --exclude=.git ./ $STAGE_FTP_USER@my.wp.address/project-folder/wp-content/themes/sg-coesfeld-theme/
The error result:
sshpass: invalid option -- 'o'
protocol version mismatch -- is your shell clean?
(see the rsync man page for an explanation)
rsync error: protocol incompatibility (code 2) at compat.c(176) [sender=3.1.1]
ERROR: Job failed: exit code 1
I am using the exact same .gitlab-ci.yml
, server, FTP account, runner and gitlab hosting successfully to auto-deploy in other git repos.
The only thing that has changed is the source git repository and the /project-folder/
.
To be honest I do not know where to start and how to track down this issue, so I am happy about any suggestions.
Your $STAGE_FTP_PASS
must be empty so the command would become
sshpass -p ssh -o StrictHostKeyChecking=no
so sshpass
would think -p ssh
is the password and -o StrictHostKeyChecking=no
is the command.
As @pynexj already has said, $STAGE_FTP_PASS
was an empty string, which caused the error. I have tried this using echo $STAGE_FTP_USER
inside my script.
While inserting the secret variables, I have checked the box [X] Protected , which has an explanation attached: This variable will be passed only to pipelines running on protected branches and tags.
Searching for protected branches I have noticed, that in Settings > Repository > Protected Branches no protected branch was set.
So I could choose between unchecking the [ ] Protected
checkbox, so that every branch can use the secret variables, or go with the more secure approach and add my branch (for example master
) as a protected branch.
Now everything works great again. Thanks again to @pynexj for pointing out what causes the problem in the script.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.