簡體   English   中英

sh:1:啟動服務器和測試:權限被拒絕

[英]sh: 1: start-server-and-test: Permission denied

我正在嘗試結合我的賽普拉斯測試在 git 上創建一個管道。 每當我嘗試這樣做時,都會以錯誤sh: 1: start-server-and-test: Permission denied結束。 我已經在谷歌上搜索了一個小時,但似乎無法弄清楚出了什么問題。 (也是 Git CI 的新功能,因此這一切都變得更加困難。)

我的 package.json 腳本:

 "scripts": {
    "build": "npx webpack-cli",
    "build:dev": "npx webpack-cli --mode=development",
    "start": "npx webpack serve",
    "watch": "npx webpack serve",
    "lint": "npx eslint src/**.js src/js/**.js",
    "cy:test": "npx cypress run",
    "test:headless": "npx cypress run --spec cypress/integration/ToDo_tests.js",
    "test": "start-server-and-test start http-get://localhost:8080 test:headless"
  },

我的 Git CI:

image: node:latest

stages:     
  - test

cypress-test-job:
  stage: test
  script:
    - cd frontend-webpack/
    - echo "Testing frontend with Cypress"
    - npm config set user 0
    - npm config set unsafe-perm true
    - npm run test
    - echo "Testing complete"

失敗管道的output:

Running with gitlab-runner 14.9.0~beta.68.g1283960c (1283960c)
  on green-5.shared.runners-manager.gitlab.com/default xS6Vzpvo
Resolving secrets
00:00
Preparing the "docker+machine" executor
00:34
Using Docker executor with image node:latest ...
Pulling docker image node:latest ...
Using docker image sha256:20c0a0be5115616fa6d27d6c72aefe8663340fd7f5fce9bc9d62728b2efe7a75 for node:latest with digest node@sha256:0b553d28086d90b9b3be3339beb97401f8c0a83c17230a37ad99ff88fdad3b3f ...
Preparing environment
00:03
Running on runner-xs6vzpvo-project-34382765-concurrent-0 via runner-xs6vzpvo-shared-1649328236-cb09d98a...
Getting source from Git repository
00:11
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/saxion.nl/hbo-ict/development-tools/web/38/.git/
Created fresh repository.
Checking out 387cff6f as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:02
Using docker image sha256:20c0a0be5115616fa6d27d6c72aefe8663340fd7f5fce9bc9d62728b2efe7a75 for node:latest with digest node@sha256:0b553d28086d90b9b3be3339beb97401f8c0a83c17230a37ad99ff88fdad3b3f ...
$ cd frontend-webpack/
$ echo "Testing frontend with Cypress"
Testing frontend with Cypress
$ npm config set user 0
$ npm config set unsafe-perm true
$ npm run test
> seminar-week5-client@1.0.0 test
> start-server-and-test start http://localhost:8080 test:headless
sh: 1: start-server-and-test: Permission denied
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

你的.gitlab-ci.yml應該是這樣的:

stages:
  - test

e2e-test:
  image: cypress/browsers:node16.14.0-slim-chrome99-ff97
  stage: test
  script:
    - npm ci
    - npm run test

我建議你使用 wait-on 而不是 start-server-and-test,為此,首先安裝 wait-on 依賴npm i wait-on並將 package.json 中的測試腳本更改為: "test":"npm run start && wait-on http://localhost:8080 && npm run test:headless

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM