gpt4 book ai didi

node.js - 通过谷歌云构建触发器部署 "sh: 1: jest: Permission denied"

转载 作者:行者123 更新时间:2023-12-05 02:56:14 26 4
gpt4 key购买 nike

我正在谷歌云平台部署一个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 并启用它们(App 引擎等)并通过命令部署:

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 部署成功,但通过触发器返回错误。

请帮忙

编辑我创建了一个 Github 存储库并重复了相同的步骤,触发器中出现了相同的错误:

已有图像(带摘要):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"
},

关于node.js - 通过谷歌云构建触发器部署 "sh: 1: jest: Permission denied",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60671752/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com