chef/artifactory-client

Artifactory Query Language Support?

Closed this issue · 1 comments

gVien commented

Hi,

I have been digging through the codes to find if there is support for Artifactory Query Language but would like to ask the question here before I dig too far.

https://www.jfrog.com/article/artifactory-query-language-aql/

We used a couple of methods (artifact_search, artifact_latest_version, artifact_versions, etc) in the artifact.rb to find what we need in Artifactory. One specific case is to find the version of an artifact but it seems that the methods search all the available versions inside maven-metadata.xml (see below for an example). It seems that if the version doesn't get append to the "versions" tag (see below) after a build, the search results will only return the available versions inside the versions tag, which might not have all the versions. After writing this paragraph, I was able to verify that this is the case.

https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-ArtifactLatestVersionSearchBasedonLayout

https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-ArtifactVersionSearch

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>one.two.three.four</groupId>
  <artifactId>someArtifactId</artifactId>
  <versioning>
    <latest>1.0.0.16</latest>
    <release>1.0.0.16</release>
    <versions>
      <version>1.0.0.2</version>
      <version>1.0.0.6</version>
      <version>1.0.0.11</version>
      <version>1.0.0.14</version>
      <version>1.0.0.15</version>
      <version>1.0.0.16</version>
    </versions>
    <lastUpdated>20170724102939</lastUpdated>
  </versioning>
</metadata>

You can make AQL queries directly with a Artifactory::Client instance like:

client = Artifactory::Client.new(endpoint: '...', username: '...')

aql_query =<<-AQL_QUERY
items.find(
  {"repo": "myrepo"}
)
AQL_QUERY

client.post("/api/search/aql", aql_query, "Content-Type" => "text/plain")