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

Add support for building projects using jib #1073

Merged
merged 21 commits into from
Oct 4, 2018

Conversation

briandealwis
Copy link
Member

Adds support for building projects using jib for maven or gradle. The implementation invokes jib:dockerBuild (Maven) / :jibDockerBuild (Gradle) to build to the local docker daemon using a predictable image name derived from the workspace and module/project settings.

Currently the internal image names are of the form

  • jib<workspace> if not project/module is specified and the workspace is a valid image name
  • jib<workspace_project if project/module is specified and the workspace_project is a valid image name
  • jib__<hex-sha1> where <hex_sha1> is the sha1 of <workspace> or <workspace>_<project> (if a project/module is specified)
    But maybe these should have a fixed image name of jib_skaffold and instead specify the above as an image tag.

Supports:

  • supports multi-project gradle projects
  • supports Maven profiles

Does not support:

  • multimodule Maven builds

pkg/skaffold/build/local/jib.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/util.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/util_windows.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib_test.go Show resolved Hide resolved
pkg/skaffold/build/local/util.go Outdated Show resolved Hide resolved
// Maven and Gradle projects often provide a wrapper to ensure a particular
// builder version is used. This function tries to resolve a wrapper
// or otherwise resolves the builder executable.
func findBuilder(builderExecutable string, wrapperScriptName string, workspace string) ([]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why return an slice of strings? only one string is returned, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to add some logs here to help debug a setup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows the wrappers are batch files, and need to be run with an explicit "cmd.exe /c wrapper.bat"

@codecov-io
Copy link

codecov-io commented Oct 2, 2018

Codecov Report

Merging #1073 into jib_skaffold will decrease coverage by 0.03%.
The diff coverage is 38.7%.

Impacted file tree graph

@@               Coverage Diff                @@
##           jib_skaffold    #1073      +/-   ##
================================================
- Coverage         43.25%   43.22%   -0.04%     
================================================
  Files                78       81       +3     
  Lines              3299     3357      +58     
================================================
+ Hits               1427     1451      +24     
- Misses             1739     1773      +34     
  Partials            133      133
Impacted Files Coverage Δ
pkg/skaffold/build/local/util.go 0% <0%> (ø)
pkg/skaffold/build/local/jib_maven.go 35% <35%> (ø)
pkg/skaffold/build/local/jib_gradle.go 42.1% <42.1%> (ø)
pkg/skaffold/build/local/jib.go 56.25% <56.25%> (+56.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 352217a...8fd3c75. Read the comment docs.

@briandealwis
Copy link
Member Author

PTAL @GoogleContainerTools/container-tools

Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, left organizational/nits comments.
I think we should merge #1058 first and then reuse what we can from there here.

pkg/skaffold/build/local/jib.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib.go Show resolved Hide resolved
pkg/skaffold/build/local/jib_test.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/jib_test.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/util.go Outdated Show resolved Hide resolved
pkg/skaffold/build/local/util_windows.go Outdated Show resolved Hide resolved
)

func (b *Builder) buildJibMaven(_ /*ctx*/ context.Context, _ /*out*/ io.Writer, _ /*workspace*/ string, _ /*a*/ *v1alpha3.JibMavenArtifact) (string, error) {
return "", errors.New("buildJibMaven is unimplemented")
func (b *Builder) buildJibMaven(ctx context.Context, out io.Writer, workspace string, a *v1alpha3.JibMavenArtifact) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should pull out maven related stuff to jib_maven.go and gradle methods to jib_gradle.go?

pkg/skaffold/build/local/jib.go Outdated Show resolved Hide resolved
@dgageot
Copy link
Contributor

dgageot commented Oct 4, 2018

Sorry @briandealwis this needs to be rebased

@dgageot
Copy link
Contributor

dgageot commented Oct 4, 2018

I left a few comments on things that could be fixed in another PR. Is tested the feature and it works!
If you need help to rebase, feel free to ping. I can even do it if you like.

@balopat balopat merged commit b819f27 into GoogleContainerTools:jib_skaffold Oct 4, 2018
@briandealwis briandealwis deleted the jib-build branch October 4, 2018 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants