自动.gitlab-ci.yml lftp配置

自动.gitlab-ci.yml lftp配置,gitlab,gitlab-ci,lftp,Gitlab,Gitlab Ci,Lftp,我正在使用lftp自动化gitlab ci部署。我运行一个脚本来部署代码,但需要上传到其他服务器的“静态”文件除外。这里是我当前代码的示例 script: - > lftp -e "mirror --exclude ^\.git.* --exclude-glob *.sql --exclude-glob *.sqlite3 --exclude-glob *.txt --exclude-glob *.csv --exclude-glob *.pyc --e

我正在使用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
这很好,但在此之后,我必须手动将静态文件上传到静态文件服务器。你能帮我一个脚本,只获取所有静态文件夹中的文件吗?静态文件夹可以在根目录中,也可以在其他文件夹中。许多Thx。

您可以使用:

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
    :并行化
  • /
    :要上载的本地目录
  • 开发站点
    :必须上传的远程目录。注意远程目录参数:
    • 如果以trail(
      dev site/
      )结束,则当前目录将上载到ftp服务器上的该目录中
    • 如果它没有以trail(
      dev site
      )结束,则当前目录将作为该目录上载到ftp服务器上
如果您想将其与GitLab CI一起用于上传静态生成的文档,下面是一个示例
.GitLab CI.yml
mkdocs
+
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"