Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

node.js - I cannot get my CI/CD deploy job to complete successfully

I've been working at this for a lot longer than I want to admit, but I cannot get my deploy to staging job to succeed. I've looked over as much documentation as I could find, and tried to follow any examples, but still no dice. At this point I get a lot of permission denied errors when removing files, and I have set the runner to be in the same group with rwx permissions as the destination and source directories. Here is my gitlab-ci.yml file,

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

And here is what I get as the response:

[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

Any help you can give would be greatly appreciated.

question from:https://stackoverflow.com/questions/65602784/i-cannot-get-my-ci-cd-deploy-job-to-complete-successfully

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For anyone who is curious I discovered that my folders had multiple users and permission sets.
This occurred because I was in the server a while back working on some issues with the server and I manually ran npm install etc. This broke my permissions. The output

rsync: delete_file: unlink(fubar/node_modules/zenscroll/package.json) failed: Permission denied (13) was the clue. I navigated to my directory ran an ls -l <directory> and this is what was returned:

/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

I then ran sudo chown -R gitlab-runner fubar and all is now working.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...