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

Understand Spring Boot Git Properties #446

Open
nebhale opened this issue Jan 10, 2020 · 6 comments
Open

Understand Spring Boot Git Properties #446

nebhale opened this issue Jan 10, 2020 · 6 comments
Labels
epic/source-metadata Issues/PRs related to providing source metadata size/md Medium level of effort status/ready Issue ready to be worked on. type/enhancement Issue that requests a new feature or improvement.

Comments

@nebhale
Copy link
Contributor

nebhale commented Jan 10, 2020

In a recent change to the CNB specification, support for adding source metadata to the created image's label was added. This spec change was designed for the case where the input to pack is a repository of source code and the buildpacks create images from that source. In this case, extraction of the source information by pack is pretty straight forward. However, there is a use-case where the input to pack is a recompiled artifact (say a Spring Boot JAR) rather than the source repository, preventing pack from determining the source metadata.

Luckily, Spring Boot natively supports embedding Git metadata into the created JAR file. pack should optionally detect this metadata if it exists, and use it for the contents of the image's source metadata.

Technical Details

The Spring Boot Maven and Gradle plugins both optionally embed this metadata. By default the location of this file is BOOT-INF/classes/git.properties. This location can be moved, but finding it at a non-default location should be out of scope of this effort.

This file follows the Java Properties File format. An example of the created file, including the standard keys, follows:

#Generated by Git-Commit-Id-Plugin
#Fri Jan 10 10:52:34 PST 2020
git.branch=master
git.build.host=hypnotoad.local
git.build.time=2020-01-10T10\:52\:34-0800
git.build.user.email=bhale@pivotal.io
git.build.user.name=Ben Hale
git.build.version=2.0.0.BUILD-SNAPSHOT
git.closest.tag.commit.count=
git.closest.tag.name=
git.commit.id=63a73f1b0f2a4f6978c19184b0ea33ad3f092913
git.commit.id.abbrev=63a73f1
git.commit.id.describe=63a73f1-dirty
git.commit.id.describe-short=63a73f1-dirty
git.commit.message.full=Spring Boot 2.2.2.RELEASE\n\nSigned-off-by\: Ben Hale <bhale@pivotal.io>
git.commit.message.short=Spring Boot 2.2.2.RELEASE
git.commit.time=2019-12-12T17\:56\:38-0800
git.commit.user.email=bhale@pivotal.io
git.commit.user.name=Ben Hale
git.dirty=true
git.local.branch.ahead=0
git.local.branch.behind=0
git.remote.origin.url=https\://github.com/nebhale/apps-manager-demo.git
git.tags=
git.total.commit.count=20

Various properties should be extracted out of this content and mapped to the expected fields in the source metadata payload.

@nebhale nebhale added the type/enhancement Issue that requests a new feature or improvement. label Jan 10, 2020
@zmackie
Copy link
Contributor

zmackie commented Jan 10, 2020

Is there a reason this should live in pack (the platform) vs a buildpack? Aren’t we sort of coupling here? I’d worried that supporting this specific case (spring) in the platform would lead to others. Maybe technically this intelligence has to live on the platform because it handles the input to the buildpacks?

@nebhale
Copy link
Contributor Author

nebhale commented Jan 10, 2020

Correct @zmackie. This is properly located in each platform because only the platform can reliably examine source information before sanitizing it for build. An example of this is that each platform will need to implement support for VCSs such as Git, Mercurial, Subversion, CVS, P4, etc. because we plan to filter out things like the .git/ directory before putting it into the build containers (i.e. buildpacks won't even have enough information to extract this information if they wanted to). Adding support for other ways of communicating source information, including from the built artifacts of the most popular enterprise frameworks, is along the same lines.

@jromero jromero added the status/triage Issue or PR that requires contributor attention. label Feb 5, 2020
@natalieparellano
Copy link
Member

@zmackie is there an epic for adding source metadata to labels?

@natalieparellano
Copy link
Member

Blocked by buildpacks/lifecycle#230

@natalieparellano natalieparellano added status/blocked Issue or PR that is blocked. See comments. size/md Medium level of effort and removed status/triage Issue or PR that requires contributor attention. labels Feb 6, 2020
@zmackie zmackie added status/ready Issue ready to be worked on. and removed status/blocked Issue or PR that is blocked. See comments. labels Feb 20, 2020
@jromero jromero added the epic/source-metadata Issues/PRs related to providing source metadata label Apr 20, 2021
@natalieparellano
Copy link
Member

@anthonydahanne any thoughts on this one?

@anthonydahanne
Copy link
Contributor

Just discussed it with @pivotal-david-osullivan , yes it would be nice to have, it's on our radar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic/source-metadata Issues/PRs related to providing source metadata size/md Medium level of effort status/ready Issue ready to be worked on. type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
Development

No branches or pull requests

5 participants