推送到多个 FTP 服务器

Push to several FTP servers

所以我有一个 gitlab 存储库,当前每次我提交时都会与 SFTP 服务器同步。现在我有另一个 SFTP 服务器,我也必须将文件推送到该服务器,但我不确定我应该如何自动执行此操作。这是我现在拥有的 yml 脚本:

stages:
  - push
  - notification

push:
  stage: push
  image: debian:stable
  before_script:
    - apt-get update -y --allow-unauthenticated
    - apt-get install -y git git-ftp --allow-unauthenticated
    
    - git config http.sslVerify "false"
    - git config --global http.sslVerify "false"
    - git config git-ftp.url "sftp://$FTP_URL/$FTP_PATH"
    - git config git-ftp.user "$FTP_USER"
    - git config git-ftp.password "$FTP_PASSWORD"
  script:
   - git ftp push -v --insecure

对多台服务器执行此操作的最佳方法是什么?谢谢

请参阅 https://github.com/git-ftp/git-ftp/blob/master/man/git-ftp.1.md 中的文档。您可以直接推送到 URL:

git ftp push -u username2 -p password2 -- "sftp://$FTP_URL2/$FTP_PATH2"

您也可以尝试利用 scopes