首页 > 解决方案 > AWS CodeBuild 中的 lerna 构建错误并出现错误:“命令失败:git rev-list”

问题描述

我是 AWS CodeBuild 的新手。

我正在设置将我的 javascript 包发布到 npm。我的回购是与 Lerna 组成的单一回购。所以,我运行脚本 lerna publish 来发布我的新版本。这在我的本地环境中运行良好。

但是如果我尝试使用由 github webhook 执行的 AWS CodeBuild,下面的消息会失败

[Container] 2020/10/15 08:54:01 Running command lerna publish
info cli using local version of lerna
lerna notice cli v3.22.1
lerna info versioning independent
lerna info ci enabled
lerna ERR! Error: Command failed: git rev-list --count ~~~~~~
lerna ERR! error: Could not read ~~~~~~~
lerna ERR! fatal: Failed to traverse parents of commit ~~~~~~
lerna ERR! 
lerna ERR! 
lerna ERR!     at makeError (/codebuild/output~~~/node_modules/execa/index.js:174:9)
lerna ERR!     at Function.module.exports.sync 

我不知道是什么问题。

这是我的 buildSpect.yml。谢谢。


version: 0.2
env:
  variables:
    REGION: "us-east-1"
    IMAGE_NAME: conekta-registry
    REGISTRY: dkr.ecr.us-east-1.amazonaws.com
    OUTPUT: json
phases:
  install:
    runtime-versions:
      python: 3.8
      nodejs: 12
  pre_build:
    commands:
      - echo $NPM_TOKEN
      - npm install -g lerna
      - yarn install
  build:
    commands:
      - lerna run build
  post_build:
    commands:
      - lerna publish

标签: gitaws-codebuildlerna

解决方案


如本期所述,AWS CodeBuild 没有.git目录。

您仍然可以使用以下方式发布:

lerna publish from-package --git-head ${CODEBUILD_RESOLVED_SOURCE_VERSION}

文档:发布命令文档


推荐阅读