You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CircleCI YAML配置解析报错:复制粘贴仍无法通过校验

Fixing the YAML Parsing Error in CircleCI Config

Let me break down what's going on here and how to fix it quickly.

The error you're seeing is a classic YAML formatting issue—YAML is extremely strict about indentation and line breaks, and your copied deploy-job-canada entry has a structural problem the parser can't resolve.

Why the error happens

When you copied deploy-job to create deploy-job-canada, you likely didn't maintain the correct indentation hierarchy. The error message tells us that after <<: *defaults, the parser expected the end of the block, but instead found steps:—this means the parser doesn't recognize steps: as a child element of deploy-job-canada because the formatting is off.

Your original deploy-job works because it has proper line breaks and indentation, but the copied version probably mashed elements together or used incorrect spacing.

Fixed YAML Config

Here's the corrected version of your config, with proper indentation and structure:

# First, ensure your defaults anchor is defined correctly (you already have this working)
defaults: &defaults
  # Example defaults content (adjust to match your actual config)
  docker:
    - image: circleci/node:14
  working_directory: ~/repo

deploy-job:
  <<: *defaults
  steps:
    - attach_workspace:
        at: ~/repo
    - run:
        name: Firebase set project-id
        command: ./node_modules/.bin/firebase use production --token=$FIREBASE_DEPLOY_TOKEN
    - run:
        name: Deploy Master to Firebase
        command: ./node_modules/.bin/firebase deploy --token=$FIREBASE_DEPLOY_TOKEN

deploy-job-canada:
  <<: *defaults
  steps:
    - attach_workspace:
        at: ~/repo
    - run:
        name: Firebase set project-id
        command: ./node_modules/.bin/firebase use canada --token=$FIREBASE_DEPLOY_TOKEN_CANADA
    - run:
        name: Deploy Master to Firebase
        command: ./node_modules/.bin/firebase deploy --token=$FIREBASE_DEPLOY_TOKEN_CANADA

Key Fixes to Note

  1. Indentation consistency: Use 2 spaces (CircleCI's recommended standard) for each nested level. Never mix tabs and spaces.
  2. Proper line breaks: Each child element (like <<: *defaults and steps:) under a job name must be on its own line, indented one level deeper than the job name.
  3. Anchor placement: The <<: *defaults merge directive must be at the same indentation level as steps—they're both direct children of the job entry.

Once you adjust the formatting to match this structure, running circleci config validate should pass without issues.

内容的提问来源于stack exchange,提问作者Lewis Smith

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 21:02:51