【问题标题】:Automated .gitlab-ci.yml lftp configuration自动化 .gitlab-ci.yml lftp 配置
【发布时间】:2017-01-13 11:22:39
【问题描述】:

我正在使用 lftp 来自动化 gitlab ci 部署。我运行一个脚本来部署我的代码,除了我需要上传到其他服务器的“静态”文件。这是我当前代码的示例。

script:
- >
  lftp
  -e "mirror
  --exclude ^\.git.*
  --exclude-glob *.sql
  --exclude-glob *.sqlite3
  --exclude-glob *.txt
  --exclude-glob *.csv
  --exclude-glob *.pyc
  --exclude settings.py
  --exclude migracion/
  --exclude static/
  --exclude ^Resources/Private/
  --exclude \.gitlab-ci.yaml
  -eRv $CI_PROJECT_DIR /pro/ject/dirs; quit;"
  sftp://$ACC

这工作正常,但在此之后,我必须手动将静态文件上传到静态文件服务器。你能帮我写一个只在所有静态文件夹中获取文件的脚本吗?静态文件夹可以位于根目录中,也可以位于其他文件夹中。非常感谢。

【问题讨论】:

    标签: gitlab gitlab-ci lftp


    【解决方案1】:

    你可以使用:

    lftp -u username,passwd ftp.foobar.cmo \
         -e "mirror -e -R -x .git -x static/ -p ./ dev-site ; quit"
    

    在哪里,在镜子里:

    • -e :删除不再存在的文件
    • -R :表示你从本地机器上传到 ftp 服务器
    • -x :指定要排除的目录。您可以拥有多个-x
    • -p:并行化
    • ./ : 你要上传的本地目录
    • dev-site :上传必须去的远程目录。注意远程目录参数:
      • 如果它以跟踪 (dev-site/) 结尾,您当前的目录将被上传 INSIDE 该目录在 ftp 服务器上
      • 如果它没有以跟踪 (dev-site) 结尾,您当前的目录将被上传 AS 该目录在 ftp 服务器上

    如果你想将它与 GitLab CI 一起使用来上传你的静态生成文档,这里有一个示例 .gitlab-ci.ymlmkdocs + lftp

    # Build static html site with mkdocs :
    build:
      stage: build
      script:
      - mkdocs build
     # first upload, exclude static files:
      - lftp -u ftp_username,$FTP_PASSWORD ftp.foobar.org -e "mirror -x static -R -p site dev ; quit"
     # upload only static to other server:
     - lftp -u ftp_username,$FTP_PASSWORD ftp.otherserv.org -e "mirror -R -p static/ remote/dir ; quit"
    

    【讨论】:

      猜你喜欢
      • 2022-04-12
      • 1970-01-01
      • 2016-07-16
      • 2023-01-03
      • 1970-01-01
      • 2023-01-13
      • 2020-02-14
      • 2019-03-14
      • 1970-01-01
      相关资源
      最近更新 更多