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

Mic*_*ant -1 api circleci postman newman

尝试运行简单的邮递员 API 调用但得到

Error calling workflow: 'workflow'
Run Code Online (Sandbox Code Playgroud)

我的.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
Run Code Online (Sandbox Code Playgroud)

collection.json 是项目的根,是邮递员的导出。

我使用的例子来自

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

这表现了:

在此处输入图片说明

当我开始在这个分支上构建时,“工作流”引用来自于 circleci 站点上的原始示例(而不是 newman),我已经替换了分支中的配置文件内容并推送了它,所以不确定为什么会出现这个引用?

这是原始屏幕:

在此处输入图片说明

我改为:

在此处输入图片说明

在此处输入图片说明

jon*_*rpe 5

如果您阅读了您遗漏的错误行(请参阅build),您就会明白为什么调用工作流时会出现错误:

# Error calling workflow: 'workflow'
# Cannot find a definition for job named build
Run Code Online (Sandbox Code Playgroud)

此要求记录在配置文件参考中(重点是我的):

如果您不使用工作流,则jobs地图必须包含名为 的作业build。此build作业是由推送到 VCS 提供程序触发的运行的默认入口点。然后可以指定其他作业并使用 CircleCI API 运行它们。

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

# Error calling workflow: 'workflow'
# Cannot find a definition for job named build
Run Code Online (Sandbox Code Playgroud)

您可以通过使用CircleCI 的本地 CLIcircleci config process .circleci/config.ymlDanny's answer 中的固定版本上运行来看到这一点。

这暗示了该问题的另一种解决方案;而不是重命名工作,提供工作流程

workflows:
  version: 2
  workflow:
    jobs:
    - build
Run Code Online (Sandbox Code Playgroud)

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

* 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>
Run Code Online (Sandbox Code Playgroud)

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

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