ARTIFACTORY: How to search for builds that contain a specific dependency

Rasul Imanov
2022-05-15 11:58

Prerequisites

Before you process with this guide, please make sure you have the following prerequisites

  • A running Artifactory 7.x 
  • Builds that contain dependencies as shown below in the next steps

Method 1: Artifactory REST API 

  1. Locate the sha1 checksum of the dependency 
  • Navigate to Application -> Build -> Build Name -> Build ID -> Build Info JSON -> "dependencies" -> "sha1"

User-added image

Alternatively, you can get the checksum of the dependency by running an "api/storage" command:curl -uadmin
"<your-artifactory-url>/artifactory/api/storage/<path-to-dependency>"
(The repo path can be found by going to Application -> Artifactory -> Builds -> select build name -> select build ID -> select module ID and Repo Path will be shown in Published Modules section)

2. Copy the sha1 checksum value of the dependency and run the below curl command to get all builds with this dependencycurl -uadmin
"<your-artifactory-url>/artifactory/api/search/dependency?sha1=<sha1-value>"

User-added image

This method will allow you to see each build that references the specific dependency identified by the sha1 checksum value you entered as input, assuming that you're tracking files in the build info system. 
You may also refer to this section in Artifactory REST API documentation for additional reference.

Method 2: Artifactory Query Language (AQL)

If you would like to simply search the dependency by its name in your builds, you may do so utilizing AQL by running the following command: 
 curl -u admin -X POST -k -H 'Content-Type:text/plain' -i
"<artifactory-url>/artifactory/api/search/aql" --data
'builds.find({"module.dependency.item.name ":{"$match":"*<dep-name>*"}})'
 
The expected response should look something like this

User-added image