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

Multi-value properties are not possible to set using Gradle plugin #567

Closed
Anatolii opened this issue Nov 3, 2021 · 0 comments · Fixed by #583
Closed

Multi-value properties are not possible to set using Gradle plugin #567

Anatolii opened this issue Nov 3, 2021 · 0 comments · Fixed by #583
Labels
gradle bug Create a report to help us improve

Comments

@Anatolii
Copy link

Anatolii commented Nov 3, 2021

When Gradle plugin is used, it is not possible to set multi-value property for a publication.
Setting it using snippet below doesn't work. Value gets set as single string.

project.tasks.artifactoryPublish.configure {
    properties.put("q.os", "win32, deb, osx")
    // or
    properties.put("q.os.2", "win32;deb;osx")
}

Usage of ; separator makes Artifactory web UI show correctly number of values for q.os.2 but value will be still considered as a single property value and it will not be possible to use REST API to search for something like q.os.2=deb.

When a new property is added from UI, using ; Artifactory will process the value as expected.

The q.os property example I got from the plugin documentation page: https://www.jfrog.com/confluence/display/JFROG/Gradle+Artifactory+Plugin

To Reproduce

I prepared following build.gradle.kts to demo the issue which you see below.
Project name in my case is jfrog-tags-issue. This is a root project also, hence all the configuration is in one place.
None of the properties options will result in a multi-value property being set correctly.

group = "artifactory.issue"

plugins {
    java
    id("com.jfrog.artifactory") version "4.24.21"
    id("maven-publish")
}

val issueDemoPublication = publishing.publications.register("issueDemo", MavenPublication::class.java) {
    from(components.getByName("java"))
}

project.tasks.artifactoryPublish.configure {
    publications(issueDemoPublication.name)

    properties.put("tag-properties", "val1")
    properties.put("tag-properties", "val2")
    properties.put("tag-properties", "val3")

    mapOf(
        "tag-properties-comma" to "val1,val2,val3",
        "tag-properties-semicolon" to "val1;val2;val3",
        "q.os" to "win32, deb, osx"
    ).forEach {
        properties.put(it.key, it.value)
    }
}

artifactory {
    setContextUrl("http://localhost:8081/artifactory")
    publish {
        repository {
            setRepoKey("maven-on-artifactory")
            setUsername("anonymous")
        }
    }
}

Run the publication

./gradlew artifactoryPublish -Pversion=0.3

For the demo I've added two more properties with , and ; using Artifactory web UI. You will recognise them by the name in the json output below.

Then we query REST API to get the properties

curl "http://localhost:8081/artifactory/api/storage/maven-on-artifactory/artifactory/issue/jfrog-tags-issue/0.3/jfrog-tags-issue-0.3.jar?properties"

which returns following:

{
  "properties" : {
    "build.name" : [ "jfrog-tags-issue" ],
    "build.number" : [ "1635953438347" ],
    "build.timestamp" : [ "1635953438316" ],
    "q.os" : [ "win32, deb, osx" ],
    "tag-properties" : [ "val1, val2, val3" ],
    "tag-properties-comma" : [ "val1,val2,val3" ],
    "tag-properties-semicolon" : [ "val1;val2;val3" ],
    "tag-ui-comma" : [ "val1,val2,val3" ],
    "tag-ui-semicolon" : [ "val1", "val2", "val3" ]
  },
  "uri" : "http://localhost:8081/artifactory/api/storage/maven-on-artifactory/artifactory/issue/jfrog-tags-issue/0.3/jfrog-tags-issue-0.3.jar"
}

Notice the tag-ui-semicolon has several strings in the values, while others have one.

Running search for the property which was set from Gradle plugin doesn't provide any results:

$ curl "http://localhost:8081/artifactory/api/search/prop?tag-properties-semicolon=val2"
{
  "results" : [ ]
}

But the one set from UI could be found:

$ curl "http://localhost:8081/artifactory/api/search/prop?tag-ui-semicolon=val2"
{
  "results" : [ {
    "uri" : "http://localhost:8081/artifactory/api/storage/maven-on-artifactory/artifactory/issue/jfrog-tags-issue/0.3/jfrog-tags-issue-0.3.jar"
  } ]
}

Expected behavior

  1. If the expected multi-value property separator is ; then tag-properties-semicolon should have same value as tag-ui-semicolon in JSON output above.
  2. Searching for a property with query like tag-properties-semicolon=val2 should find the artifact by one of the multiple property's values, like it's possible for tag-ui-semicolon.
  3. The documentation should suggest the correct separator.
    E.g. Set Item Properties mention it's possible to set os=win,linux with , separator. But why then , doesn't work from Artifactory UI? Also in Gradle plugin when , separator is used, Artifactory UI doesn't handle it if it was multi-value.

Screenshots

Screenshot 2021-11-03 at 17 23 32

Versions

  • Gradle Artifactory plugin version: 4.24.21 (from Gradle plugins portal)
  • Operating system: macOS 11.6.1, Ubuntu 18.04, Ubuntu 20.04
  • Artifactory Version: Open source license 7.27.9 rev 72709900 (running inside Docker image, used for the demo above); EnterpriseX license 7.21.12 rev 72112900 (on which the issue was originally noticed)

Additional context

Here's the PUT request that was printed during the demo artifact upload from Artifactory Gradle plugin with a build running with --debug property:

Executing request PUT /artifactory/maven-on-artifactory/artifactory/issue/jfrog-tags-issue/0.3/jfrog-tags-issue-0.3.jar;build.timestamp=1635953438316;build.name=jfrog-tags-issue;tag-properties-semicolon=val1%3Bval2%3Bval3;q.os=win32%2C+deb%2C+osx;tag-properties=val1%2C+val2%2C+val3;build.number=1635953438347;tag-properties-comma=val1%2Cval2%2Cval3 HTTP/1.1
@Anatolii Anatolii added the gradle bug Create a report to help us improve label Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gradle bug Create a report to help us improve
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant