You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitLab CI中Docker镜像内rsync仅部分同步失败问题

GitLab CI Docker环境下第二次rsync同步报错排查问题

环境:Ubuntu 22 LTS系统,Docker 28.0.4版本(构建号b8034c0),已制作好可用镜像。当前在GitLab CI中执行两次rsync同步任务:

  • 第一次:将/local-one/同步到user@server.com:/remote-one(始终成功)
  • 第二次:将/local-two/同步到user@server.com:/remote-two(仅在GitLab CI环境报错,本地手动执行无问题)

成功的rsync命令

rsync -avz --delete --exclude-from="./exclude-one.txt" -e "ssh -oStrictHostKeyChecking=no -i /path/to/key.ppk" --progress  /local-one/ user@server.com:/remote-one

失败的rsync命令

rsync -avz --delete --exclude-from="./exclude-two.txt" -e "ssh -oStrictHostKeyChecking=no -i /path/to/key.ppk" --progress  /local-two/ user@server.com:/remote-two

错误信息

rsync: [client] failed to open exclude file "./exclude-two.txt": No such file or directory (2)
rsync error: error in file IO (code 11) at exclude.c(1482) [client=3.2.7]

异常现象

完整脚本流程中,第二次rsync命令的前后执行cat ./exclude-two.txt都能正常显示文件内容,但rsync就是报错找不到该文件:

rsync -avz --delete --exclude-from="./exclude-one.txt" -e "ssh -oStrictHostKeyChecking=no -i /path/to/key.ppk" --progress  /local-one/ user@server.com:/remote-one
cat ./exclude-two.txt
rsync -avz --delete --exclude-from="./exclude-two.txt" -e "ssh -oStrictHostKeyChecking=no -i /path/to/key.ppk" --progress  /local-two/ user@server.com:/remote-two
cat ./exclude-two.txt

已尝试的排查操作

  • 更换exclude-two.txt文件
  • 修改exclude-two.txt的存放路径
  • 通过cat命令生成新的exclude文件供rsync使用
  • 手动执行docker run -ts myimage:tag进入镜像,逐条执行脚本命令,无任何错误

仅在GitLab CI运行镜像时出现该问题,且GitLab日志显示第一次rsync已正常完成。

有没有人遇到过类似问题?

内容的提问来源于stack exchange,提问作者Bob Ramsey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 07:05:07