【问题标题】:CircleCI version 2.1 - "Cannot find a definition for command named 'restore-cache'"CircleCI 2.1 版-“找不到名为‘restore-cache’的命令的定义”
【发布时间】:2019-07-28 00:11:36
【问题描述】:

我目前正在尝试使用 CircleCI 2.1 版中提供的commands 功能,以便我可以重用一些常用命令。我正在使用 CLI 命令进行测试:

circleci config process ./.circleci/config.latest.yaml > ./.circleci/config.yml

但我收到以下错误:

Error: Error calling workflow: 'main'
Error calling job: 'build'
Error calling command: 'build_source'
Cannot find a definition for command named restore-cache

似乎restore-cache 在直接的版本 2 配置文件中工作得很好,但是当我尝试使用 process 处理 2.1 文件时,它会大惊小怪。

下面是我的config.yaml 文件的编辑版本,希望对它有一些用处。如果有任何其他有用的信息,请告诉我。

version: 2.1

defaults: &defaults
  /**
   *  Unimportant stuff
   */

aliases:
  - &restore-root-cache
    keys:
      - v1-deps-{{ .Branch }}-{{ checksum "package.json" }}
      - v1-deps-{{ .Branch }}
      - v1-deps

commands:
  build_source:
    description: 'Installs dependencies, then builds src, builds documentation, and runs tests'
    steps:
      - restore-cache: *restore-root-cache
      - other-commands...

jobs:
  build:
    <<: *defaults
    steps:
      - checkout
      - build_source

workflows:
  version: 2.1
  main:
    jobs:
      - build:
          filters:
            branches:
              ignore: develop

【问题讨论】:

    标签: continuous-integration circleci circleci-2.0 circleci-workflows


    【解决方案1】:

    恢复缓存是一个特殊的步骤,需要在一个作业下。不是另一个命令。

    【讨论】:

      【解决方案2】:

      命令是restore_cache(带下划线),而不是restore-cache(带破折号)https://circleci.com/docs/2.0/configuration-reference/#restore_cache

      它应该在命令中工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-08-24
        • 2021-03-31
        • 1970-01-01
        • 2019-04-15
        • 1970-01-01
        • 2021-05-20
        • 1970-01-01
        • 2021-02-16
        相关资源
        最近更新 更多