vite-plugin-sentry
vite-plugin-sentry copied to clipboard
"not a git repository (or any of the parent directories)" error when building in AWS CodeBuild
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?
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.
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.
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 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 yep, in that case you should try to pass commit/repo
as environment variables due to build stage and use them with process.env
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...
Ah, i thought problem was solved:) Did you use auto: false
?
Yes, I did, and it didn't resolve the error.