Search code examples
amazon-web-servicesaws-codepipelineaws-codebuild

Resolve not a git repository error in code build?


getting the following error in logs in the build phase of the pipeline:

> vue-cli-service build --mode=development

 ERROR  Error loading vue.config.js:
 ERROR  Error: Git returned with status 128: fatal: not a git repository (or any parent up to mount point /codebuild)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Error: Git returned with status 128: fatal: not a git repository (or any parent up to mount point /codebuild)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
    at handleProcessResult (/codebuild/output/src410036127/src/app/node_modules/git-describe/lib/git-describe.js:76:19)
    at wrapper (/codebuild/output/src410036127/src/app/node_modules/lodash/lodash.js:5255:19)
    at gitDescribe (/codebuild/output/src410036127/src/app/node_modules/git-describe/lib/git-describe.js:46:16)
    at wrapper (/codebuild/output/src410036127/src/app/node_modules/lodash/lodash.js:5255:19)
    at Object.<anonymous> (/codebuild/output/src410036127/src/app/vue.config.js:3:40)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] predeploy:dev: `vue-cli-service build --mode=development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] predeploy:dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-12-13T06_27_32_689Z-debug.log

[Container] 2022/12/13 06:27:32 Command did not exit successfully npm run predeploy:dev exit status 1
[Container] 2022/12/13 06:27:32 Phase complete: BUILD State: FAILED
[Container] 2022/12/13 06:27:32 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm run predeploy:dev. Reason: exit status 1

If I run the code build directly (not by pipeline) it builds fine.


Solution

  • We need to add the following permission in code-build service role:

    {
                "Action": [
                    "codestar-connections:UseConnection"
                ],
                "Resource": //arn,
                "Effect": "Allow"
            }