CircleCI 中的 YAML 配置文件解析错误

迈克尔·迪尔克斯

我一直在我的 Github 存储库上试用 CircleCI,但它的配置文件存在一些问题。我查看了 Node.js 管道的模板,并从中设计了我自己的测试。它应该做的就是安装 Node.js,检查它的版本,然后安装最新的 npm 包。提交文件后,CircleCI 告诉我我的构建失败了。当我查看日志时,我注意到 YAML 配置文件本身没有正确解析。通过在 Google 上搜索,我找不到任何有用的信息,对我的代码结构进行一些基本调整似乎也无济于事。

这是我的配置文件:

version: 2.0
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/node:12.15.0

      # 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

    steps:
     - checkout
  - run:
          name: "Update files"
          command: |
            curl -sSL "https://nodejs.org/dist/v12.15.0/node-v12.15.0.tar.gz"
            npm @latest -g
  - run:
        name: "Check current version of Node.js"
        command: node -v

这是日志文件:

#!/bin/sh -eo pipefail
#!/bin/sh -eo pipefail
# Unable to parse YAML
# while parsing a block mapping
#  in 'string', line 7, column 3:
#       build:
#       ^
# expected <block end>, but found '-'
#  in 'string', line 21, column 3:
#       - run:
#       ^
# 
# -------
# Warning: This configuration was auto-generated to show you the message above.
# Don't rerun this job. Rerunning will have no effect.
false
kn_pavan

yaml对缩进/空格数非常严格。在您的情况下,问题在于步骤的缩进

version: 2.0
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/node:12.15.0

      # 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

    steps:
      - checkout
      - run:
            name: "Update files"
            command: |
              curl -sSL "https://nodejs.org/dist/v12.15.0/node-v12.15.0.tar.gz"
              npm @latest -g
      - run:
            name: "Check current version of Node.js"
            command: node -v

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章