diff --git a/build-info-extractor-gradle/src/test/java/org/jfrog/gradle/plugin/artifactory/GradlePluginTest.java b/build-info-extractor-gradle/src/test/java/org/jfrog/gradle/plugin/artifactory/GradlePluginTest.java index b159afa5a..8a45ec06e 100644 --- a/build-info-extractor-gradle/src/test/java/org/jfrog/gradle/plugin/artifactory/GradlePluginTest.java +++ b/build-info-extractor-gradle/src/test/java/org/jfrog/gradle/plugin/artifactory/GradlePluginTest.java @@ -73,7 +73,7 @@ public void publicationsTest(String gradleVersion) throws IOException { BuildResult buildResult = runGradle(gradleVersion, envVars, false); // Check results checkBuildResults(artifactoryManager, buildResult, VersionNumber.parse(gradleVersion).getMajor() >= 6, localRepo1); - checkBuildInfoProps(artifactoryManager, buildResult); + checkArtifactsProps(artifactoryManager); // Cleanup Pair buildDetails = getBuildDetails(buildResult); cleanTestBuilds(buildDetails.getLeft(), buildDetails.getRight(), null); @@ -87,6 +87,7 @@ public void publicationsTestKotlinDsl(String gradleVersion) throws IOException { BuildResult buildResult = runGradle(gradleVersion, envVars, false); // Check results checkBuildResults(artifactoryManager, buildResult, VersionNumber.parse(gradleVersion).getMajor() >= 6, localRepo1); + checkArtifactsProps(artifactoryManager); // Cleanup Pair buildDetails = getBuildDetails(buildResult); cleanTestBuilds(buildDetails.getLeft(), buildDetails.getRight(), null); diff --git a/build-info-extractor-gradle/src/test/java/org/jfrog/gradle/plugin/artifactory/Utils.java b/build-info-extractor-gradle/src/test/java/org/jfrog/gradle/plugin/artifactory/Utils.java index 1825d601b..2e26accdc 100644 --- a/build-info-extractor-gradle/src/test/java/org/jfrog/gradle/plugin/artifactory/Utils.java +++ b/build-info-extractor-gradle/src/test/java/org/jfrog/gradle/plugin/artifactory/Utils.java @@ -12,6 +12,7 @@ import org.jfrog.build.api.Build; import org.jfrog.build.api.Dependency; import org.jfrog.build.api.Module; +import org.jfrog.build.api.dependency.PropertySearchResult; import org.jfrog.build.api.util.CommonUtils; import org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager; @@ -245,23 +246,21 @@ private static void checkBuildInfoModules(Build buildInfo, int expectedModules, } /** - * Check expected build info properties is found on each published artifacts. + * Check expected properties is found on each published artifacts. * * @param artifactoryManager - ArtifactoryManager client - * @param buildResult - The build results */ - static void checkBuildInfoProps(ArtifactoryManager artifactoryManager, BuildResult buildResult) throws IOException { - Build buildInfo = getBuildInfo(artifactoryManager, buildResult); - for (Module module : buildInfo.getModules()) { - for (Artifact artifact : module.getArtifacts()) { - Properties properties = artifact.getProperties(); - assertNotNull(properties); - assertEquals(properties.getProperty("qa.level"), "basic"); - assertEquals(properties.getProperty("q.os"), "win32"); - assertEquals(properties.getProperty("q.os"), "deb"); - assertEquals(properties.getProperty("q.os"), "osx"); - } - } + static void checkArtifactsProps(ArtifactoryManager artifactoryManager) throws IOException { + // Test single value prop + PropertySearchResult artifacts = artifactoryManager.searchArtifactsByProperties("gradle.test.single.value.key=basic"); + assertTrue(artifacts.getResults().size()>=12); + // Test multi value props + artifacts = artifactoryManager.searchArtifactsByProperties("gradle.test.multi.values.key=val1"); + assertTrue(artifacts.getResults().size()>= 12); + artifacts = artifactoryManager.searchArtifactsByProperties("gradle.test.multi.values.key=val2"); + assertTrue(artifacts.getResults().size()>=12); + artifacts = artifactoryManager.searchArtifactsByProperties("gradle.test.multi.values.key=val3"); + assertTrue(artifacts.getResults().size()>= 12); } /** diff --git a/build-info-extractor-gradle/src/test/resources/integration/gradle-example-publish/build.gradle b/build-info-extractor-gradle/src/test/resources/integration/gradle-example-publish/build.gradle index 12d12c65c..da9bc5b29 100644 --- a/build-info-extractor-gradle/src/test/resources/integration/gradle-example-publish/build.gradle +++ b/build-info-extractor-gradle/src/test/resources/integration/gradle-example-publish/build.gradle @@ -69,6 +69,9 @@ artifactory { publications('mavenJava', 'ivyJava') publishArtifacts = true // Properties to be attached to the published artifacts. + properties.put("gradle.test.multi.values.key", "val1, val2, val3") + properties.put("gradle.test.single.value.key", "basic") + properties = ["gradle.test.single.value.key": 'basic', "gradle.test.multi.values.key": 'val1, val2, val3'] publishPom = true // Publish generated POM files to Artifactory (true by default) publishIvy = true // Publish generated Ivy descriptor files to Artifactory (true by default) } diff --git a/build-info-extractor-gradle/src/test/resources/integration/gradle-kts-example-publish/build.gradle.kts b/build-info-extractor-gradle/src/test/resources/integration/gradle-kts-example-publish/build.gradle.kts index e977e62b5..f6c683cba 100644 --- a/build-info-extractor-gradle/src/test/resources/integration/gradle-kts-example-publish/build.gradle.kts +++ b/build-info-extractor-gradle/src/test/resources/integration/gradle-kts-example-publish/build.gradle.kts @@ -81,6 +81,8 @@ configure { publications("mavenJava", "ivyJava") setPublishArtifacts(true) // Properties to be attached to the published artifacts. + properties.put("gradle.test.multi.values.key", "val1, val2, val3") + properties.put("gradle.test.single.value.key", "basic") setPublishPom(true) // Publish generated POM files to Artifactory (true by default) setPublishIvy(true) // Publish generated Ivy descriptor files to Artifactory (true by default) } diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DeploymentUrlUtils.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DeploymentUrlUtils.java index 517313a73..5105497ae 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DeploymentUrlUtils.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DeploymentUrlUtils.java @@ -87,14 +87,20 @@ public static String encodePath(String unescaped) { return escaped; } + public static String buildMatrixParamsString(ArrayListMultimap matrixParams, boolean encodeProperties) throws UnsupportedEncodingException { StringBuilder matrix = new StringBuilder(); if (matrixParams != null && !matrixParams.isEmpty()) { for (String propertyKey : matrixParams.keySet()) { - for (String propertyValue : matrixParams.get(propertyKey)) { - matrix.append(";").append(encodeProperties ? encode(propertyKey) : propertyKey) - .append("=").append(encodeProperties ? encode(propertyValue) : propertyValue); + for (String multiPropertyValue : matrixParams.get(propertyKey)) { + // Due to known bug in Artifactory, in order to support multi values properties + // we add a statement to each value separately. + for (String propertyValue:multiPropertyValue.split(",")) { + propertyValue = propertyValue.trim(); + matrix.append(";").append(encodeProperties ? encode(propertyKey) : propertyKey) + .append("=").append(encodeProperties ? encode(propertyValue) : propertyValue); + } } } }