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

Let maven access the .git directory #200

Open
sovereignstack opened this issue Oct 17, 2022 · 3 comments
Open

Let maven access the .git directory #200

sovereignstack opened this issue Oct 17, 2022 · 3 comments
Labels
type:question A user question

Comments

@sovereignstack
Copy link

sovereignstack commented Oct 17, 2022

We use the maven commit-id plugin to push git version information inside every build so that build can be traced back to commit-id. This plugin takes git metadata from .git directory and creates a files that's inserted into the build. However, buildpacks apparently does not keep the .git directory visible/accessible to the build process and hence the maven plugin fails to work. Leading to the error:
Failed to execute goal pl.project13.maven:git-commit-id-plugin:4.9.10:revision (default) on project fooservice: .git directory is not found! Please specify a valid [dotGitDirectory] in your pom.xml

Note: We use kpack for build

Describe the Enhancement

It would be nice if the .git directory remains accessible by the build process. Many build scripts would expect that directory to be present for a similar requirement.

Possible Solution

Please let the .git directory be accessible to the build process. If that can't be made the default, provide a flag to do so.

Motivation

Baking source commit-id info into a build is a common practice. It helps in debugging/reporting issues. I read about the git build-pack. It puts commit id into an environment variable. But I can't use that as I need a git.proerties file that the above plugin generates. This file is later used by Spring (framework) at runtime to present build information at a specific http endpoint.

@dmikusa
Copy link
Contributor

dmikusa commented Oct 18, 2022

Not sure this is exactly what you want, but have you tried using:

$BP_INCLUDE_FILES | Colon separated list of glob patterns to match source files. Any matched file will be retained in the final image. Defaults to `` (i.e. nothing).

$BP_EXCLUDE_FILES | Colon separated list of glob patterns to match source files. Any matched file will be specifically removed from the final image. If include patterns are also specified, then they are applied first and exclude patterns can be used to further reduce the fileset.

The default behavior is to remove all of the files not necessary from the final image, so after build we delete everything except the compiled assets. Prior to that, during the build, all of your source code and everything that was included with the build should be present. I know when I do a pack build, the .git files are there. I don't know about kpack, maybe it has specific behavior here. Do things work correctly if you do a pack build of your app?

@dmikusa dmikusa added the type:question A user question label Oct 18, 2022
@sovereignstack
Copy link
Author

I don't want to retain any extra files after the build. I want the .git directory to be present till the build finishes so that the build process can access data from it. Problem is, the .git directory is missing so the build fails. Buildpacks only presents the source code to the build process and not the .git directory.

About .git directory: When you checkout a git project, you get a .git directory at the base of the project directory. The maven git-commit-id-plugin is supposed to read git revision information from this .git directory and then write a summary to git.properties.

@dmikusa
Copy link
Contributor

dmikusa commented Oct 18, 2022

If .git isn't present, it's probably not a buildpack issue. We don't delete files from /workspace until after the build finishes. As previously mentioned, I did a pack build and confirmed I could see .git files. Can you try a pack build and see if that works for you? If it does, then you're probably hitting an issue with kpack and not the buildpack.

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

No branches or pull requests

2 participants