vite-plugin-sentry icon indicating copy to clipboard operation
vite-plugin-sentry copied to clipboard

"not a git repository (or any of the parent directories)" error when building in AWS CodeBuild

Open metalmarker opened this issue 1 year ago • 8 comments

I'm using AWS CodeBuild to build an express app configured with the plugin, I'm getting this error during build: fatal: not a git repository (or any of the parent directories): .git.

Am I missing a specific configuration flag that I need to turn off?

metalmarker avatar May 31 '23 02:05 metalmarker

Hi! Does your app builds without using plugin? If so - try to use ignoreMissing/ignoreEmpty options at setCommits section in your config, but i think this error is more likely not related to the plugin.

ikenfin avatar Jun 01 '23 09:06 ikenfin

hi @ikenfin - I've isolated the issue to the plugin. Specifically, the errors occurs when (1) the plugin is included and (2) there's no git repo in the hierarchy. I've added setCommits: { ignoreMissing: true, ignoreEmpty: true }, but the error persists.

metalmarker avatar Jun 01 '23 16:06 metalmarker

Try also set auto: false in setCommits section - seems that there is no git repository present at building phase. This will prevent sentry from tracking commit which you could set manual using commit and repo options like that:

setCommits: {
  auto: false,
  commit: "<commit_hash>",
  repo: "<repository>"
}

ikenfin avatar Jun 13 '23 13:06 ikenfin

@ikenfin adding this configuration option did not help.

You're right that there's no git repo in the hierarchy of folders where build is executed - and there shouldn't be one. A bit more context on why I believe that this is a common use case: I'm using AWS CodePipeline as my CI/CD pipeline. CodePipeline is made out of 3 stages: Source, Build and Deploy. The source stage is cloning (not pulling) the source files from the GitHub repo, and therefore, the result of the source stage is not a repo (.git) but rather just a clone of the source files hierarchy. And this is the folder that the Build stage sees, and that's why the error takes place.

Conversely, when I'm building on my development machine, there are no errors because the git repo exists in the hierarchy.

To summarize, I think that building out of a git clone vs. a pull is a rather common use case. Perhaps the commit and repo attributes can be provided via environment variables in lieu of a full git access?

metalmarker avatar Jun 13 '23 16:06 metalmarker

@metalmarker yep, in that case you should try to pass commit/repo as environment variables due to build stage and use them with process.env

ikenfin avatar Jun 15 '23 06:06 ikenfin

I can set the commit / repo fields, but the "fatal: not a git repository" error remains. Doesn't seem right to have a fatal error during build...

metalmarker avatar Jun 15 '23 15:06 metalmarker

Ah, i thought problem was solved:) Did you use auto: false?

ikenfin avatar Jun 16 '23 06:06 ikenfin

Yes, I did, and it didn't resolve the error.

metalmarker avatar Jun 16 '23 17:06 metalmarker