node.js - 通过 Google Cloud 构建触发器部署“sh: 1: jest: Permission denied”
问题描述
我正在谷歌云平台上部署一个 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 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"
},
推荐阅读
- javascript - 通过加入两个数组来创建新数组
- javascript - 在 React/JS 中使用复杂路径进行动态导入
- ruby-on-rails - 不需要在每个 rswag 响应块中调用参数
- r - 如何使用 anova() 在虚拟交互中找到主效应的总体意义
- c# - dotnet 核心配置绑定不起作用
- java - Spring Boot 自定义启动器 - 无法导入自定义启动器类
- list - Flutter List、详情页和待办事项
- jquery - 数据表只计算特定列中的行数
- ios - 在 OS X 上安装 OpenSSL 时出现架构不支持错误
- javascript - Angular Reactive Forms 动态嵌套数组检测失去焦点时的变化