我正在尝试将我的springboot教程项目与CircleCi 集成.
我的项目位于Github存储库内的子目录中,我从CircleCi得到以下错误.
目标需要执行项目,但此目录中没有POM(/ home/circleci/recipe).请验证您是否从正确的目录中调用了Maven.
我无法弄清楚如何告诉circle-ci我的项目在一个子目录中.我尝试了几件事,以及试图cd进入"食谱",但它不起作用,甚至感觉不对.
这是我的项目的结构:
Spring-tutorials
|
+-- projectA
|
+-- recipe
| | +--pom.xml
Run Code Online (Sandbox Code Playgroud)
这是我的 config.yml
# Java Maven CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/openjdk:8-jdk
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
working_directory: ~/recipe
environment:
# Customize the JVM maximum heap limit
MAVEN_OPTS: -Xmx3200m
steps:
- checkout
- run: cd recipe/; ls -la; pwd;
# Download and cache dependencies
- restore_cache:
keys:
- recipe-{{ checksum "pom.xml" }}
# fallback to using the latest cache if no exact match is found
- recipe-
- run: cd recipe; mvn dependency:go-offline
- save_cache:
paths:
- ~/recipe/.m2
key: recipe-{{ checksum "pom.xml" }}
# run tests!
- run: mvn integration-test
Run Code Online (Sandbox Code Playgroud)
Kev*_*off 31
我设法解决了这个问题.我相信的结合
working_directory: ~/spring-tutorial/recipe
Run Code Online (Sandbox Code Playgroud)
和
- checkout:
path: ~/spring-tutorial
Run Code Online (Sandbox Code Playgroud)
使它工作.
这是我的工作config.yml:
# Java Maven CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs:
build:
working_directory: ~/spring-tutorial/recipe
docker:
# specify the version you desire here
- image: circleci/openjdk:8-jdk
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
environment:
# Customize the JVM maximum heap limit
MAVEN_OPTS: -Xmx3200m
steps:
- checkout:
path: ~/spring-tutorial
# Download and cache dependencies
- restore_cache:
keys:
- recipe-{{ checksum "pom.xml" }}
# fallback to using the latest cache if no exact match is found
- recipe-
- run: mvn dependency:go-offline
- save_cache:
paths:
- ~/.m2
key: recipe-{{ checksum "pom.xml" }}
# run tests!
- run: mvn integration-test
Run Code Online (Sandbox Code Playgroud)
Min*_*wzy 11
我有点困惑所以我想进一步澄清
构建子目录以定义您的工作空间的关键解决方案,在这种情况下,是它的子文件夹,因此它将像这样定义
working_directory: ~/repo/sub_folder
Run Code Online (Sandbox Code Playgroud)
并结帐到
- checkout:
path: ~/repo
Run Code Online (Sandbox Code Playgroud)
像这样
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:7.10
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4
working_directory: ~/repo/sub_folder
steps:
- checkout:
path: ~/repo
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
# run tests!
- run: npm test
Run Code Online (Sandbox Code Playgroud)
如果有人尝试运行 npm 命令但cd未按预期工作,即:
cd subdir && npm run command
Run Code Online (Sandbox Code Playgroud)
您可以使用--prefixnpm 的选项。
- run:
name: Run start command in recipe folder
command: npm --prefix ./recipe run start
# then in same file
- run:
name: Run test command in app folder
command: npm --prefix ./app run test
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4559 次 |
| 最近记录: |