代码之家  ›  专栏  ›  技术社区  ›  Kevin Amiranoff

Circleci 2.0使用子目录

  •  12
  • Kevin Amiranoff  · 技术社区  · 7 年前

    我正在尝试整合我的 springboot 使用Circleci的教程项目。

    我的项目位于Github存储库中的一个子目录中,我从CircleCI中得到以下错误。

    目标需要执行一个项目,但没有POM 目录(/home/circleci/recipe)。请验证您调用了maven 从正确的目录。

    我不知道如何告诉Circle CI我的项目在一个子目录中。我试过两件事,也试过 cd 在“配方”里面,但它不起作用,甚至感觉不对劲。

    以下是我的项目结构:

    Spring-tutorials
     |
     +-- projectA
     |    
     +-- recipe
     |   | +--pom.xml
    

    这是我的 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
    
    2 回复  |  直到 7 年前
        1
  •  25
  •   Kevin Amiranoff    7 年前

    我设法解决了这个问题。我相信

    working_directory: ~/spring-tutorial/recipe
    

    以及

      - checkout:
          path: ~/spring-tutorial
    

    成功了。

    这是我的工作 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
    
        2
  •  2
  •   Artur Aleksanyan    6 年前

    如果有人试图运行npm命令 cd 不按预期工作,例如:

    cd subdir && npm run command
    

    你可以用 --prefix NPM选项。

    - 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