自动化.gitlab-ci.yml lftp配置 [英] Automated .gitlab-ci.yml lftp configuration
问题描述
我正在使用lftp自动化gitlab ci部署.我运行一个脚本来部署我的代码,除了需要上传到其他服务器的静态"文件.这是我当前代码的示例.
I'm using lftp to automated gitlab ci deployments. I run a script to deploy my code, except 'static' files that I need to upload to other server. Here a sample of my current code.
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.
This works fine but after this, I have to upload by hand the static files to the static files server. Can you help me with a script that only fetch files in all static folders? Static folders can be in root and inside other folders. Many 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
:并行化 -
./
:您要上传的本地目录 -
dev-site
:必须上载的远程目录.注意远程dir参数:- 如果以结尾(
dev-site/
)结尾,则当前目录将被 INSIDE 上载到ftp服务器上 - 如果它不以结尾(
dev-site
)结尾,则您当前的目录将被 AS 上载到ftp服务器上
-e
: remove files that doesn't exist anymore-R
: means you upload from local machine to ftp server-x
: specify a directory to exlude. You can have more than one-x
-p
: parallelize./
: local dir you want uploaddev-site
: remote dir where upload have to go. Take care about the remote dir parameter :- if it end with a trail (
dev-site/
), your current dir will be uploaded INSIDE this dir on the ftp server - if it doesn't end with a trail (
dev-site
), your current dir will be uploaded AS this dir on the ftp server
如果要与GitLab CI一起使用它来上传静态生成的文档,请参见
.gitlab-ci.yml
和mkdocs
+lftp
的示例:If yout to use this with GitLab CI to upload your static-generated documentation, here is an example
.gitlab-ci.yml
withmkdocs
+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"
这篇关于自动化.gitlab-ci.yml lftp配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- if it end with a trail (
- 如果以结尾(