lerna build error in AWS CodeBuild with Error: 'Command failed: git rev-list '

814 Views Asked by At

I am new to AWS CodeBuild.

I am setting for publishing my javascript package to npm. My repo is composed as mono repo with Lerna. So, I run script lerna publish to release my new version. This works in my local environment well.

But If I try to use AWS CodeBuild executed by github webhook, It is failed with this message below

[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 

I don't know what problem is.

this is my buildSpect.yml. Thanks.


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

1

There are 1 best solutions below

0
On

As described in this issue AWS CodeBuild doesn't have a .git directory.

You can still publish with:

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

Documentation: publish command docs