我正在使用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。
发布于 2017-01-13 23:25:51
您可以使用:
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:并行化./:您想上传的本地dirdev-site:远程dir上传必须去的地方。注意远程dir参数:dev-site/)结尾,您当前的dir将被上传到ftp服务器的中--此dir位于ftp服务器上。dev-site)结尾,那么您当前的dir将以的形式上传到ftp服务器上。
如果yout与GitLab CI一起使用它来上载静态生成的文档,下面是一个带有mkdocs + lftp的.gitlab-ci.yml示例。
# 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"https://stackoverflow.com/questions/41633518
复制相似问题