我在这方面工作的时间比我想承认的要长得多,但我无法成功部署到暂存工作。我查看了尽可能多的文档,并尝试遵循任何示例,但仍然没有骰子。在这一点上,我在删除文件时收到很多权限被拒绝的错误,并且我已将运行程序设置为与目标和源目录具有 rwx 权限的同一组中。这是我的 gitlab-ci.yml 文件,
stages:
- build
- deploy
build:
stage: build
tags:
- Build PWA
script:
- echo "Building Deploy Package"
- npm install
- npm run build
- echo "Build successful"
artifacts:
expire_in: 1 hour
paths:
- build
only:
- master
deploy_staging:
stage: deploy
tags:
- Deploy Staging
script:
- echo "Deploying to server"
- rsync -av --delete /home/gitlab-runner/builds/qRT2eXnz/0/AssemblersInc/developers/fubar /home/root1/example/
- echo "Deployed"
environment:
name: staging
url: <redacted>
only:
- master
这是我得到的回应:
<块引用>[0K[0K[36;1mGetting source from Git repository[0;m
[0;m[32;1mFetching changes with git depth set to 50...[0;m
Reinitialized existing Git repository in /home/gitlab-runner/builds/qRT2eXnz/0/AssemblersInc/developers/fubar/.git/
[32;1mChecking out f941bda3 as master...[0;m
Removing .next/
Removing node_modules/
[32;1mSkipping Git submodules setup[0;m
section_end:1609962749:get_sources
[0Ksection_start:1609962749:step_script
[0K[0K[36;1mExecuting "step_script" stage of the job script[0;m
[0;m[32;1m$ echo "Deploying to server"[0;m
Deploying to server
[32;1m$ rsync -av --delete /home/gitlab-runner/builds/qRT2eXnz/0/AssemblersInc/developers/fubar /home/root1/example/[0;m
sending incremental file list
rsync: chgrp "/home/root1/example/fubar" failed: Operation not permitted (1)
rsync: delete_file: unlink(fubar/node_modules/zenscroll/zenscroll.js) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/zenscroll/zenscroll-min.js) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/zenscroll/package.json) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/zenscroll/README.md) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/zenscroll/LICENSE) failed: Permission denied (13)
cannot delete non-empty directory: fubar/node_modules/zenscroll
rsync: delete_file: rmdir(fubar/node_modules/zenscroll) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/yargs/node_modules/path-exists/readme.md) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/yargs/node_modules/path-exists/package.json) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/yargs/node_modules/path-exists/license) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/yargs/node_modules/path-exists/index.js) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/yargs/node_modules/path-exists/index.d.ts) failed: Permission denied (13)
cannot delete non-empty directory: fubar/node_modules/yargs/node_modules/path-exists
rsync: delete_file: rmdir(fubar/node_modules/yargs/node_modules/path-exists) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/yargs/node_modules/p-try/readme.md) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/yargs/node_modules/p-try/package.json) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/yargs/node_modules/p-try/license) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/yargs/node_modules/p-try/index.js) failed: Permission denied (13)
rsync: delete_file: unlink(fubar/node_modules/yargs/node_modules/p-try/index.d.ts) failed: Permission denied (13)
cannot delete non-empty directory: fubar/node_modules/yargs/node_modules/p-try
如果您能提供任何帮助,我们将不胜感激。
答案 0 :(得分:0)
对于好奇的人,我发现我的文件夹有多个用户和权限集。
发生这种情况是因为我在服务器中处理了服务器的一些问题,并且我手动运行了 npm install 等。这破坏了我的权限。输出
rsync: delete_file: unlink(fubar/node_modules/zenscroll/package.json) 失败:权限被拒绝 (13)
是线索。
我导航到我的目录运行了一个 ls -l <directory>
,这是返回的内容:
/example> ls -l fubar
total 1144
-rw-r--r-- 1 gitlab-runner users 586 Jan 6 14:50 adalConfig.js
drwxrwxr-x 1 user1 wheel 16 Dec 3 09:52 api
-rw-r--r-- 1 gitlab-runner users 275 Jan 6 14:50 App.js
-rw-r--r-- 1 gitlab-runner users 8805 Jan 6 14:50 ASM_Watermark.svg
drwxrwxr-x 1 user1 wheel 990 Jan 6 14:53 components
-rw-r--r-- 1 gitlab-runner users 283 Jan 6 14:50 next.config.js
-rw-r--r-- 1 gitlab-runner users 75 Jan 6 14:50 next-env.d.ts
drwxr-xr-x 1 user1 wheel 24534 Dec 31 11:15 node_modules
-rw-r--r-- 1 gitlab-runner users 2495 Jan 6 14:50 package.json
然后我运行了 sudo chown -R gitlab-runner fubar
,现在一切正常。