0
votes

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
Possibly a problem with git. Which git version (git --version) is AWS CodeBuild using? Does AWS CodeBuild has access to the git history?a1300
@a1300 Instance used git 2.27.0 version. And I tried printing out git log, But it is failed with this message [Container] 2020/10/16 04:26:44 Running command git log error: Could not read [commit 1] fatal: Failed to traverse parents of commit [commit2]Minsik Park

1 Answers

0
votes

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