Unknown Command - LFTP

1.8k views Asked by At

I'm using LFTP on Gitlab CI to deploy a set of files. I've got this working nicely on one server that I've set up (a staging server using SFTP). However, on my client's server, I can't seem to connect. The server is setup using FTP and I have to use plain/unsecure mode to connect via Filezilla - it does connect and work fine (although I'll be giving some advice to use SFTP in the future).

When I try to do the same using LFTP through the .gitlab-ci.yml file I get the following error:

Unknown command `ftp.example.com'.
mirror: Not connected
ERROR: Build failed: exit code 1

I suspect that this is because of using plain FTP but I've tried changing hosts, putting ftp:// infront of the host and a few other commands using set but having no luck.

Here's (an edited version of) my .gitlab-ci.yml file:

stages:
  - build-staging
  - build-production

variables:
  EXCLUDE: "--exclude '.htaccess' --exclude-glob .git* --exclude '.git/' --exclude 'wp-config.php'"
  SOURCE_DIR: "./"

  # STAGING
  DEST_DIR: "/"
  HOST_STAGING: "sftp://123.456.789"
  USERNAME_STAGING: "user"
  PASSWORD_STAGING: "password"

  # PRODUCTION
  DEST_DIR_PROD: "/"
  HOST_PROD: "ftp.example.com"
  USERNAME_PROD: "user"
  PASSWORD_PROD: "password"

job1:
  stage: build-staging
  environment: staging
  script:
  - apt-get update -qq && apt-get install -y -qq lftp
  - echo "Deploying"
  - lftp -c "set ftp:ssl-allow no; set sftp:auto-confirm yes; open -u $USERNAME_STAGING,$PASSWORD_STAGING $HOST_STAGING; mirror -Rv --ignore-time --parallel=10 $EXCLUDE $SOURCE_DIR $DEST_DIR_STAGING"
  only:
  - staging
  tags:
  - 2gb

job2:
  stage: build-production
  environment: production
  when: manual
  script:
  - apt-get update -qq && apt-get install -y -qq lftp
  - echo "Deploying"
  - lftp -c "set ftp:ssl-allow no; open -u $USERNAME_PROD,$PASSWORD_PROD $HOST_PROD; mirror -Rv --ignore-time --parallel=10 $EXCLUDE $SOURCE_DIR $DEST_DIR_PROD"
  only:
  - production
  tags:
  - 2gb

Any help would be great, thanks!

1

There are 1 answers

0
0Neji On BEST ANSWER

This was due to a special characters in the password - my password ended with & which caused lftp to expect a different command. To fix this, I removed the quotes and escaped the & with a |, like so:

PASSWORD_PROD: password\&