Skip to content

Commit 36946d2

Browse files
authored
Merge pull request #1895 from briandealwis/jibconsole
Configure Jib builds to use plain progress updates
2 parents 1127984 + 76921d6 commit 36946d2

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

pkg/skaffold/jib/jib_gradle.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ func getCommandGradle(ctx context.Context, workspace string, a *latest.JibGradle
4848

4949
// GenerateGradleArgs generates the arguments to Gradle for building the project as an image.
5050
func GenerateGradleArgs(task string, imageName string, a *latest.JibGradleArtifact, skipTests bool) []string {
51-
args := []string{gradleCommand(a, task), "--image=" + imageName}
51+
// disable jib's rich progress footer; we could use `--console=plain`
52+
// but it also disables colour which can be helpful
53+
args := []string{"-Djib.console=plain", gradleCommand(a, task), "--image=" + imageName}
5254
if skipTests {
5355
args = append(args, "-x", "test")
5456
}

pkg/skaffold/jib/jib_gradle_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ func TestGenerateGradleArgs(t *testing.T) {
150150
skipTests bool
151151
out []string
152152
}{
153-
{latest.JibGradleArtifact{}, false, []string{":task", "--image=image"}},
154-
{latest.JibGradleArtifact{Flags: []string{"-extra", "args"}}, false, []string{":task", "--image=image", "-extra", "args"}},
155-
{latest.JibGradleArtifact{}, true, []string{":task", "--image=image", "-x", "test"}},
156-
{latest.JibGradleArtifact{Project: "project"}, false, []string{":project:task", "--image=image"}},
157-
{latest.JibGradleArtifact{Project: "project"}, true, []string{":project:task", "--image=image", "-x", "test"}},
153+
{latest.JibGradleArtifact{}, false, []string{"-Djib.console=plain", ":task", "--image=image"}},
154+
{latest.JibGradleArtifact{Flags: []string{"-extra", "args"}}, false, []string{"-Djib.console=plain", ":task", "--image=image", "-extra", "args"}},
155+
{latest.JibGradleArtifact{}, true, []string{"-Djib.console=plain", ":task", "--image=image", "-x", "test"}},
156+
{latest.JibGradleArtifact{Project: "project"}, false, []string{"-Djib.console=plain", ":project:task", "--image=image"}},
157+
{latest.JibGradleArtifact{Project: "project"}, true, []string{"-Djib.console=plain", ":project:task", "--image=image", "-x", "test"}},
158158
}
159159

160160
for _, tt := range testCases {

pkg/skaffold/jib/jib_maven.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ func getCommandMaven(ctx context.Context, workspace string, a *latest.JibMavenAr
4848

4949
// GenerateMavenArgs generates the arguments to Maven for building the project as an image.
5050
func GenerateMavenArgs(goal string, imageName string, a *latest.JibMavenArtifact, skipTests bool) []string {
51-
args := mavenArgs(a)
51+
// disable jib's rich progress footer on builds; we could use --batch-mode
52+
// but it also disables colour which can be helpful
53+
args := []string{"-Djib.console=plain"}
54+
args = append(args, mavenArgs(a)...)
5255

5356
if skipTests {
5457
args = append(args, "-DskipTests=true")

pkg/skaffold/jib/jib_maven_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ func TestGenerateMavenArgs(t *testing.T) {
175175
skipTests bool
176176
out []string
177177
}{
178-
{latest.JibMavenArtifact{}, false, []string{"--non-recursive", "prepare-package", "jib:goal", "-Dimage=image"}},
179-
{latest.JibMavenArtifact{}, true, []string{"--non-recursive", "-DskipTests=true", "prepare-package", "jib:goal", "-Dimage=image"}},
180-
{latest.JibMavenArtifact{Profile: "profile"}, false, []string{"--activate-profiles", "profile", "--non-recursive", "prepare-package", "jib:goal", "-Dimage=image"}},
181-
{latest.JibMavenArtifact{Profile: "profile"}, true, []string{"--activate-profiles", "profile", "--non-recursive", "-DskipTests=true", "prepare-package", "jib:goal", "-Dimage=image"}},
182-
{latest.JibMavenArtifact{Module: "module"}, false, []string{"--projects", "module", "--also-make", "package", "-Dimage=image"}},
183-
{latest.JibMavenArtifact{Module: "module"}, true, []string{"--projects", "module", "--also-make", "-DskipTests=true", "package", "-Dimage=image"}},
184-
{latest.JibMavenArtifact{Module: "module", Profile: "profile"}, false, []string{"--activate-profiles", "profile", "--projects", "module", "--also-make", "package", "-Dimage=image"}},
185-
{latest.JibMavenArtifact{Module: "module", Profile: "profile"}, true, []string{"--activate-profiles", "profile", "--projects", "module", "--also-make", "-DskipTests=true", "package", "-Dimage=image"}},
178+
{latest.JibMavenArtifact{}, false, []string{"-Djib.console=plain", "--non-recursive", "prepare-package", "jib:goal", "-Dimage=image"}},
179+
{latest.JibMavenArtifact{}, true, []string{"-Djib.console=plain", "--non-recursive", "-DskipTests=true", "prepare-package", "jib:goal", "-Dimage=image"}},
180+
{latest.JibMavenArtifact{Profile: "profile"}, false, []string{"-Djib.console=plain", "--activate-profiles", "profile", "--non-recursive", "prepare-package", "jib:goal", "-Dimage=image"}},
181+
{latest.JibMavenArtifact{Profile: "profile"}, true, []string{"-Djib.console=plain", "--activate-profiles", "profile", "--non-recursive", "-DskipTests=true", "prepare-package", "jib:goal", "-Dimage=image"}},
182+
{latest.JibMavenArtifact{Module: "module"}, false, []string{"-Djib.console=plain", "--projects", "module", "--also-make", "package", "-Dimage=image"}},
183+
{latest.JibMavenArtifact{Module: "module"}, true, []string{"-Djib.console=plain", "--projects", "module", "--also-make", "-DskipTests=true", "package", "-Dimage=image"}},
184+
{latest.JibMavenArtifact{Module: "module", Profile: "profile"}, false, []string{"-Djib.console=plain", "--activate-profiles", "profile", "--projects", "module", "--also-make", "package", "-Dimage=image"}},
185+
{latest.JibMavenArtifact{Module: "module", Profile: "profile"}, true, []string{"-Djib.console=plain", "--activate-profiles", "profile", "--projects", "module", "--also-make", "-DskipTests=true", "package", "-Dimage=image"}},
186186
}
187187

188188
for _, tt := range testCases {

pkg/skaffold/plugin/environments/gcb/jib_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ func TestJibMavenBuildSteps(t *testing.T) {
2929
skipTests bool
3030
args []string
3131
}{
32-
{false, []string{"--non-recursive", "prepare-package", "jib:dockerBuild", "-Dimage=img"}},
33-
{true, []string{"--non-recursive", "-DskipTests=true", "prepare-package", "jib:dockerBuild", "-Dimage=img"}},
32+
{false, []string{"-Djib.console=plain", "--non-recursive", "prepare-package", "jib:dockerBuild", "-Dimage=img"}},
33+
{true, []string{"-Djib.console=plain", "--non-recursive", "-DskipTests=true", "prepare-package", "jib:dockerBuild", "-Dimage=img"}},
3434
}
3535
for _, tt := range testCases {
3636
artifact := &latest.Artifact{
@@ -63,8 +63,8 @@ func TestJibGradleBuildSteps(t *testing.T) {
6363
skipTests bool
6464
args []string
6565
}{
66-
{false, []string{":jibDockerBuild", "--image=img"}},
67-
{true, []string{":jibDockerBuild", "--image=img", "-x", "test"}},
66+
{false, []string{"-Djib.console=plain", ":jibDockerBuild", "--image=img"}},
67+
{true, []string{"-Djib.console=plain", ":jibDockerBuild", "--image=img", "-x", "test"}},
6868
}
6969
for _, tt := range testCases {
7070
artifact := &latest.Artifact{

0 commit comments

Comments
 (0)