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

问题描述 投票:0回答:1

我一直在我的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
node.js github yaml circleci
1个回答
1
投票

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
© www.soinside.com 2019 - 2024. All rights reserved.