Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
metalmarker opened this issue May 31, 2023 · 8 comments

Comments

@metalmarker
Copy link

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?

@ikenfin
Copy link
Owner

ikenfin commented Jun 1, 2023

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.

@metalmarker
Copy link
Author

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.

@ikenfin
Copy link
Owner

ikenfin commented Jun 13, 2023

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>"
}

@metalmarker
Copy link
Author

@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?

@ikenfin
Copy link
Owner

ikenfin commented Jun 15, 2023

@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 ikenfin closed this as completed Jun 15, 2023
@metalmarker
Copy link
Author

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...

@ikenfin
Copy link
Owner

ikenfin commented Jun 16, 2023

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

@ikenfin ikenfin reopened this Jun 16, 2023
@metalmarker
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants