circleci 中的邮递员 - 调用工作流时出错:'workflow'

Postman in circleci - Error calling workflow: 'workflow'

正在尝试 运行 简单的邮递员 API 呼叫但收到

Error calling workflow: 'workflow'

我的.circleci/config.yml

$ cat .circleci/config.yml 
version: 2.1
orbs:
  newman: postman/newman@0.0.2
jobs:
  newman-collection-run:
    executor: newman/postman-newman-docker
    steps:
      - checkout
      - newman/newman-run:
          collection: ./collection.json

collection.json 是项目的根目录,是 postman 的导出。

我正在使用

中的示例

https://circleci.com/orbs/registry/orb/postman/newman

显示:

当我开始在此分支上构建时,"workflow" 参考来自 circleci 站点上的原始示例(不是 newman),我已经替换了分支中的配置文件内容并将其推送,所以不是确定为什么会出现此参考资料?

这是原始屏幕:

我改成:

我认为原始 config.yml 文件缺少 build: 步骤,该步骤出现在 executor: 行之前。

version: 2.1
orbs:
  newman: postman/newman@0.0.2
jobs:
  build:
    executor: newman/postman-newman-docker
    steps:
      - checkout
      - newman/newman-run:
          collection: ./collection.json

如果您阅读遗漏的错误行(参见 the build),您会看到为什么调用工作流时出错:

# Error calling workflow: 'workflow'
# Cannot find a definition for job named build

此要求已记录在案 in the config file reference(强调我的):

If you are not using workflows, the jobs map must contain a job named build. This build job is the default entry-point for a run that is triggered by a push to your VCS provider. It is possible to then specify additional jobs and run them using the CircleCI API.

但是为什么它要在名为workflow的工作流中寻找名为build的作业呢?因为如果您不明确提供工作流程,CircleCI 使用以下默认值:

workflows:
  version: 2
  workflow:
    jobs:
    - build

您可以使用 CircleCI's Local CLI to run circleci config process .circleci/config.yml on the fixed version in 查看此内容。

这表明问题的另一种解决方案; 提供工作流程:

,而不是重命名作业
version: 2.1
orbs:
  newman: postman/newman@0.0.2
jobs:
  newman-collection-run:
    executor: newman/postman-newman-docker
    steps:
      - checkout
      - newman/newman-run:
          collection: ./collection.json
workflows:
  version: 2
  workflow:
    jobs:
    - newman-collection-run

作为旁注,在查看我是否能弄清楚您在原始失败构建中看到的消息时,这就是我遇到的:

* 37737f0 - (HEAD -> master, origin/master, origin/HEAD) config (22 hours ago) <Michael Durrant>
* e04efa0 - config (22 hours ago) <Michael Durrant>
*   e640e4e - merge into master (26 hours ago) <Michael Durrant>
|\
| * cc16160 - config (27 hours ago) <Michael Durrant>
| * 13e0ad5 - config (28 hours ago) <Michael Durrant>
| * e4df02c - config (28 hours ago) <Michael Durrant>
| * b287102 - config (28 hours ago) <Michael Durrant>
| * 14bd61c - config (28 hours ago) <Michael Durrant>
| * 0f81d84 - config (28 hours ago) <Michael Durrant>
| * ccd06b6 - config (28 hours ago) <Michael Durrant>
| * 2b909f3 - config (28 hours ago) <Michael Durrant>
| * 4b15bca - config (28 hours ago) <Michael Durrant>
| * 240c591 - config (28 hours ago) <Michael Durrant>
| * 50096a9 - config (28 hours ago) <Michael Durrant>
| * ad9fe60 - config (28 hours ago) <Michael Durrant>
| * 7c19205 - config (28 hours ago) <Michael Durrant>
| * 3c0a3b9 - config (28 hours ago) <Michael Durrant>
| * 2d1954e - config (29 hours ago) <Michael Durrant>
| * 4e1f087 - config (29 hours ago) <Michael Durrant>
| * 9413b68 - config (29 hours ago) <Michael Durrant>
| * 942d493 - config (29 hours ago) <Michael Durrant>
| * e8412b8 - config (29 hours ago) <Michael Durrant>
| * c136702 - Add .circleci/config.yml (30 hours ago) <Michael Durrant>
| * 2203710 - Add .circleci/config.yml (30 hours ago) <Michael Durrant>
| * 94a084e - Add .circleci/config.yml (30 hours ago) <Michael Durrant>
| * ec40356 - Add .circleci/config.yml (30 hours ago) <Michael Durrant>
| * 6964057 - Add .circleci/config.yml (30 hours ago) <Michael Durrant>
* | 4e5c9d1 - coinfig (30 hours ago) <Michael Durrant>
* | cbf49fd - workflow name (30 hours ago) <Michael Durrant>
* | 6245ae1 - workflow name (30 hours ago) <Michael Durrant>
* | fdf52b5 - workflow name (30 hours ago) <Michael Durrant>
* | 0c4c455 - workflow name (30 hours ago) <Michael Durrant>
|/
* 7c31fb6 - update circleci config (30 hours ago) <Michael Durrant>

这不是使用 git 的健康方式;如果您不打算给未来的自己足够的上下文来理解正在发生的变化,我建议您在将更改引入主控时压缩掉所有冗余提交。

请注意,您可以通过 运行 circleci config validate 使用 CLI 在本地获取有关基本配置文件失败的错误消息,从而节省了推送所有无法工作的提交的循环。