【发布时间】:2019-04-20 13:28:21
【问题描述】:
我有一个包含 两个子项目的存储库。只是为了完整性,前端项目和 firebase 云功能项目(都使用单独的 package.jsons)。现在对于这个项目,我想同时开始两个工作。但我无法使用 CircleCI 完成设置。我没有任何缓存配置。
项目结构
-creepy-stories
-.circleci
-cloud-functions
-functions
package.json
-frontend
package.json
config.yml
version: 2.1
jobs:
cloud-functions:
docker:
- image: circleci/node:10.8.0
working_directory: ~/creepy-stories/cloud-functions/functions
steps:
- checkout
- run: npm install
- run: npm run lint
- run: npm run build
frontend:
docker:
- image: circleci/node:10.8.0
working_directory: ~/creepy-stories/frontend
steps:
- checkout
- run: npm install
- run: npm run lint
- run: npm run build
- run: npm run test:coverage
workflows:
version: 2
cloud-functions_and_frontend:
jobs:
- cloud-functions
- frontend
所以现在我想我的问题是环境找不到我的 package.json 文件。打印的错误如下所示:
npm 运行 lint
#!/bin/bash -eo pipefail
npm run lint
npm ERR! path /home/circleci/creepy-stories/frontend/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/circleci/creepy-stories/frontend/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/circleci/.npm/_logs/2019-04-20T13_08_45_252Z-debug.log
Exited with code 254
我不知道在我的配置中设置两次工作目录是否正确,但至少设置了两次diff。工作。
更新
如果我签出项目的根目录然后cd 到所需的文件夹并执行脚本,我设法让它工作。但这并不是真正的 DRY(不要重复自己)也许你们中的一些人有更好的解决方案:
version: 2.1
jobs:
cloud-functions:
docker:
- image: circleci/node:10.8.0
working_directory: ~/creepy-stories
steps:
- checkout
- run: cd cloud-functions/functions && npm install
- run: cd cloud-functions/functions && npm run lint
- run: cd cloud-functions/functions && npm run build
web:
docker:
- image: circleci/node:10.8.0
working_directory: ~/creepy-stories
steps:
- checkout
- run: cd web && npm install
- run: cd web && npm run lint
- run: cd web && npm run build
- run: cd web && npm run test:coverage
workflows:
version: 2
concurrently:
jobs:
- cloud-functions
- web
【问题讨论】:
-
作业是否同时开始?我想这是第一件事。您是否有两个可用的构建服务器(即付费计划)来允许这样做?
-
您已为其中一项工作报告了
npm run lint,npm install是否对这两项工作都成功了?如果没有,你会发布两个输出吗? -
不,我不需要为 CI 流程构建服务器。是的,npm install 确实成功了。
-
“不,我不需要为 CI 流程构建服务器”。您误解了我的评论 - 我在问您是否有多个 CircleCI 服务器来实现您正在寻求的并行性。
标签: continuous-integration yaml circleci