Skip to content

Commit

Permalink
Handle Gradle system properties with spaces (jfrog#2357)
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi authored Dec 20, 2023
1 parent 0553c3a commit 1fd4226
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func GradleCmd(c *cli.Context) (err error) {
return err
}
printDeploymentView := log.IsStdErrTerminal()
gradleCmd := gradle.NewGradleCommand().SetConfiguration(buildConfiguration).SetTasks(strings.Join(filteredGradleArgs, " ")).SetConfigPath(configFilePath).SetThreads(threads).SetDetailedSummary(detailedSummary || printDeploymentView).SetXrayScan(xrayScan).SetScanOutputFormat(scanOutputFormat)
gradleCmd := gradle.NewGradleCommand().SetConfiguration(buildConfiguration).SetTasks(filteredGradleArgs).SetConfigPath(configFilePath).SetThreads(threads).SetDetailedSummary(detailedSummary || printDeploymentView).SetXrayScan(xrayScan).SetScanOutputFormat(scanOutputFormat)
err = commands.Exec(gradleCmd)
result := gradleCmd.Result()
defer cliutils.CleanupResult(result, &err)
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20231130093251-25c79868c10c
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231220111402-c8c1e14358a8

// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231218161600-36dbad03f5c2
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20231220105505-e62769dde9da

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.3.2-0.20231130091721-6d742be8bc7a
replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20231220102935-c8776c613ad8

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20231126134442-14887b84b87a
// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.3.2-0.20231130091721-6d742be8bc7a
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jedib0t/go-pretty/v6 v6.4.0 h1:YlI/2zYDrweA4MThiYMKtGRfT+2qZOO65ulej8GTcVI=
github.com/jedib0t/go-pretty/v6 v6.4.0/go.mod h1:MgmISkTWDSFu0xOqiZ0mKNntMQ2mDgOcwOkwBEkMDJI=
github.com/jfrog/build-info-go v1.9.17 h1:sUA6V3P8i+awYlK7dkwm4l6IuLE2W964F5Pb18x95HA=
github.com/jfrog/build-info-go v1.9.17/go.mod h1:/5VZXH2Ud0IK3cOFwPykjwPOaEcHhzzbjnRiou+YKpM=
github.com/jfrog/build-info-go v1.8.9-0.20231220102935-c8776c613ad8 h1:eAMet7vShbCBSL4QCia/F7pvtPHUGPqVqpvv3Y0cOkw=
github.com/jfrog/build-info-go v1.8.9-0.20231220102935-c8776c613ad8/go.mod h1:/5VZXH2Ud0IK3cOFwPykjwPOaEcHhzzbjnRiou+YKpM=
github.com/jfrog/gofrog v1.3.2 h1:TktKP+PdZdxjkYZxWWIq4DkTGSYtr9Slsy+egZpEhUY=
github.com/jfrog/gofrog v1.3.2/go.mod h1:AQo5Fq0G9nDEF6icH7MYQK0iohR4HuEAXl8jaxRuT6Q=
github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY=
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
github.com/jfrog/jfrog-cli-core/v2 v2.47.6 h1:k8elejLkXA+4SCExynlMElYDFtMUb0TSWc7CFkpFVMc=
github.com/jfrog/jfrog-cli-core/v2 v2.47.6/go.mod h1:p/hr1BkO3BVSVOMkAL599FAQaBK7O+HPHHvcdwm+jKs=
github.com/jfrog/jfrog-client-go v1.35.2 h1:JtGqf7KK+wcx/Pf5b0MUrkvMc+tCtIi0cB5TxFjQxnk=
github.com/jfrog/jfrog-client-go v1.35.2/go.mod h1:p80RAyfQQ78M2r5LUw1uUTA8yxTmTNoPy7eJ4IzOge0=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231220111402-c8c1e14358a8 h1:pcF3UC/sST+jGtsio3UdK0+1bOOGRIZr0hc2owWhfJ0=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231220111402-c8c1e14358a8/go.mod h1:5fV8ru7uMkW+V6xvWdUhAQC3dBHL2IrFZgC9crEZIus=
github.com/jfrog/jfrog-client-go v1.28.1-0.20231220105505-e62769dde9da h1:t56rae4Ut2XDvubtxTbrjUk4neWvu+KcwlDlJ5BYBMc=
github.com/jfrog/jfrog-client-go v1.28.1-0.20231220105505-e62769dde9da/go.mod h1:0NN5REuCDly9u0FtZxmb1wcOBr1cVR/gPazyZSO8Zs0=
github.com/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk=
github.com/jszwec/csvutil v1.8.0/go.mod h1:/E4ONrmGkwmWsk9ae9jpXnv9QT8pLHEPcCirMFhxG9I=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down
14 changes: 7 additions & 7 deletions gradle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestGradleBuildConditionalUpload(t *testing.T) {
oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath))
defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir)
execFunc := func() error {
return runJfrogCliWithoutAssertion("gradle", "clean artifactoryPublish", "-b"+buildGradlePath, "--scan")
return runJfrogCliWithoutAssertion("gradle", "clean", "artifactoryPublish", "-b"+buildGradlePath, "--scan")
}
testConditionalUpload(t, execFunc, searchSpec, tests.GetGradleDeployedArtifacts()...)
cleanGradleTest(t)
Expand All @@ -61,7 +61,7 @@ func TestGradleWithDeploymentView(t *testing.T) {
defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir)
assertPrintedDeploymentViewFunc, cleanupFunc := initDeploymentViewTest(t)
defer cleanupFunc()
assert.NoError(t, runJfrogCliWithoutAssertion("gradle", "clean artifactoryPublish", "-b"+buildGradlePath))
assert.NoError(t, runJfrogCliWithoutAssertion("gradle", "clean", "artifactoryPublish", "-b"+buildGradlePath))
assertPrintedDeploymentViewFunc()
cleanGradleTest(t)
}
Expand All @@ -76,7 +76,7 @@ func TestGradleBuildWithServerID(t *testing.T) {
buildNumber := "1"
// Windows compatibility
buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/")
runJfrogCli(t, "gradle", "clean artifactoryPublish", "-b"+buildGradlePath, "--build-name="+tests.GradleBuildName, "--build-number="+buildNumber)
runJfrogCli(t, "gradle", "clean", "artifactoryPublish", "-b"+buildGradlePath, "--build-name="+tests.GradleBuildName, "--build-number="+buildNumber)
clientTestUtils.ChangeDirAndAssert(t, oldHomeDir)
// Validate
searchSpec, err := tests.CreateSpec(tests.SearchAllGradle)
Expand Down Expand Up @@ -111,8 +111,8 @@ func TestGradleBuildWithServerIDAndDetailedSummary(t *testing.T) {
buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/")

// Test gradle with detailed summary without buildinfo props.
filteredGradleArgs := []string{"clean artifactoryPublish", "-b" + buildGradlePath}
gradleCmd := gradle.NewGradleCommand().SetConfiguration(new(utils.BuildConfiguration)).SetTasks(strings.Join(filteredGradleArgs, " ")).SetConfigPath(filepath.Join(destPath, "gradle.yaml")).SetDetailedSummary(true)
filteredGradleArgs := []string{"clean", "artifactoryPublish", "-b" + buildGradlePath}
gradleCmd := gradle.NewGradleCommand().SetConfiguration(new(utils.BuildConfiguration)).SetTasks(filteredGradleArgs).SetConfigPath(filepath.Join(destPath, "gradle.yaml")).SetDetailedSummary(true)
assert.NoError(t, commands.Exec(gradleCmd))
// Validate sha256
assert.NotNil(t, gradleCmd.Result())
Expand All @@ -121,7 +121,7 @@ func TestGradleBuildWithServerIDAndDetailedSummary(t *testing.T) {
}

// Test gradle with detailed summary + buildinfo.
gradleCmd = gradle.NewGradleCommand().SetConfiguration(utils.NewBuildConfiguration(tests.GradleBuildName, buildNumber, "", "")).SetTasks(strings.Join(filteredGradleArgs, " ")).SetConfigPath(filepath.Join(destPath, "gradle.yaml")).SetDetailedSummary(true)
gradleCmd = gradle.NewGradleCommand().SetConfiguration(utils.NewBuildConfiguration(tests.GradleBuildName, buildNumber, "", "")).SetTasks(filteredGradleArgs).SetConfigPath(filepath.Join(destPath, "gradle.yaml")).SetDetailedSummary(true)
assert.NoError(t, commands.Exec(gradleCmd))
// Validate sha256
tests.VerifySha256DetailedSummaryFromResult(t, gradleCmd.Result())
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestGradleBuildWithServerIDWithUsesPlugin(t *testing.T) {
oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath))
buildName := tests.GradleBuildName
buildNumber := "1"
runJfrogCli(t, "gradle", "clean artifactoryPublish -b "+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber)
runJfrogCli(t, "gradle", "clean", "artifactoryPublish", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber)
changeWD(t, oldHomeDir)
// Validate
searchSpec, err := tests.CreateSpec(tests.SearchAllGradle)
Expand Down

0 comments on commit 1fd4226

Please sign in to comment.