通过 Google Cloud 内部版本触发器"sh: 1: jest: 权限被拒绝"



我正在谷歌云平台中部署一个nodejs应用程序。

我的cloudbuild.yaml看起来是这样的:

steps:
- name: "gcr.io/cloud-builders/npm"
args: ["install"]
- name: "gcr.io/cloud-builders/npm"
args: ["run", "test"]
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]

我设置了所有的API并启用了它们(应用程序引擎等(,并通过以下命令进行部署:

gcloud builds submit --config cloudbuild.yaml .

部署是成功的,并且步骤已经通过(通过Jest进行测试(。

但是,当部署是通过Bitbucket存储库触发时,我在步骤1(测试步骤(中得到了这个错误:

Already have image (with digest): gcr.io/cloud-builders/npm
> server@1.0.0 test /workspace
> jest --detectOpenHandles
sh: 1: jest: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! server@1.0.0 test: `jest --detectOpenHandles`
npm ERR! Exit status 126
npm ERR! 
npm ERR! Failed at the server@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /builder/home/.npm/_logs/2020-03-13T13_42_08_361Z-debug.log

因此,通过gcloud SDK部署是成功的,但通过触发器返回错误。

请帮忙

EDIT我创建了一个Github repo,并重复了相同的步骤,触发器中出现了相同的错误:

已经有图像(带摘要(:gcr.io/cloud-builders/npm

> server@1.0.0 test /workspace
> jest --detectOpenHandles
sh: 1: jest: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! server@1.0.0 test: `jest --detectOpenHandles`
npm ERR! Exit status 126
npm ERR! 
npm ERR! Failed at the server@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /builder/home/.npm/_logs/2020-03-13T14_09_58_093Z-debug.log

已修复

我在package.json中更改了测试脚本,改为:

"scripts": {
"start": "node index.js",
"test": "jest",
"test:watch": "jest --watch"
},

至:

"scripts": {
"start": "node index.js",
"test": "sh node_modules/.bin/jest",
"test:watch": "jest --watch"
},

最新更新