Skip to content

CI 流水线失败

错误信息

                错误: 作业失败 — exit code 1
              

快速摘要

步骤 in CI 流水线 (构建, 测试, lint) returned 非-零 exit code, causing 流水线到 失败.

为什么发生

  • 测试失败 — code 有 bug or 测试是 不正确

  • 构建步骤失败 due 到 compilation 错误 or missing dependency

  • linting 步骤找到 code quality issues

  • 流水线配置是 不正确 (错误 commands, missing steps)

最小示例

✗ 错误代码
steps:
  - run: npm test  # a test fails, pipeline stops
  - run: npm run build  # never reached
✓ 修复代码
# Fix the failing test first
# Then the pipeline passes:
steps:
  - run: npm test  # all tests pass
  - run: npm run build  # runs successfully

failing 测试停止流水线. fix 地址测试失败所以流水线能 continue 到构建步骤.

如何诊断

  • 检查流水线 logs for failing 步骤

  • Identify 哪个步骤失败 and 读取错误消息

  • Reproduce 失败 locally 使用相同 commands

  • 检查如果失败是 due 到 flaky 测试 or 环境 issue

如何修复

  • Fix code 那个 caused 测试 or 构建到 失败

  • 更新测试如果它 是不正确 or outdated

  • Fix 流水线配置 (正确 commands, proper 环境)

  • Re-运行流水线之后 fixing issue

如何预防

  • 运行测试 locally 之前 pushing code

  • Use pre-提交 Hook 到 catch issues early

  • Keep 流水线配置 version-controlled and tested

相关资源

← 返回语言