当我推送时,在我的服务器上,我没有我的项目,一切都很好(显然):
rsync --exclude=".git" -e ssh -avz --delete-after . $SSH_USER@$SSH_HOST:blog_symfony/
building file list ... done
created directory blog_symfony
[...]
sent 44,533,927 bytes received 5,523 bytes 5,239,935.29 bytes/sec
total size is 238,959,003 speedup is 5.37
当我第二次按的时候,它会对我产生任何影响:
rsync: [generator] delete_file: rmdir(project/blog_symfony/project/blog_symfony) failed: Permission denied (13)
rsync: [generator] delete_file: rmdir(project/blog_symfony) failed: Permission denied (13)
deleting project/blog_symfony/translations/.gitignore
deleting project/blog_symfony/translations/
[...]
它会在我的服务器端的blog_symfony文件夹中为我创建一个“project”文件夹
annot delete non-empty directory: project/blog_symfony
cannot delete non-empty directory: project
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
sent 13,924 bytes received 175 bytes 28,198.00 bytes/sec
total size is 238,959,004 speedup is 16,948.65
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 1
我的gitlab-ci:
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config'
script:
- ls
- apt-get update && apt-get install rsync -y
- ssh $SSH_USER@$SSH_HOST "ls"
- rsync --exclude=".git" -e ssh -avz --delete-after . $SSH_USER@$SSH_HOST:blog_symfony/
- ssh $SSH_USER@$SSH_HOST "cd blog_symfony && docker-compose build && docker-compose up"
在ls -l中,我有一个由rsync编写的文件夹,它不可能从gitlab-ci中删除:
drwxrwxr-x 3 root root 4096 Dec 14 23:26 project
我认为这不正常,这是我第一次在symfony项目中使用gitlab-ci。
谢谢你的帮忙
1条答案
按热度按时间yeotifhr1#
ls -l
:我有一个由rsync
编写的文件夹,无法从GitLab CI中删除。检查该文件夹是否在第一次执行
docker-compose up
后创建:如果您Docker映像使用bind mount在内部将其自身作为USER root
执行,则它会将文件/文件夹作为root
写入。这将妨碍正常操作(在服务器上,在容器外),就像您的
rsync
,因为根文件将是i的方式。