Preparation:

XRAY: How can I automate the scanning of previously deployed builds?

AuthorFullName__c
Elina Floim
articleNumber
000005217
ft:sourceType
Salesforce
FirstPublishedDate
2022-03-06T13:35:08Z
lastModifiedDate
2022-03-06
VersionNumber
9

Before executing the script to scan the builds, we should first prepare the needed build information, which will be then used as input for the script. We will use AQL in order to retrieve the builds list from Artifactory, parse the result using jq, and then append the parsed information into a file called builds.json:

curl -uadmin:password -X POST -H 'Content-Type:text/plain' http://JFROG_URL/artifactory/api/search/aql --data "builds.find()" | jq -cr > builds.json

The AQL query can be used based on the desired results. The above results will return all of the builds, and it is important to note that if Artifactory holds a large number of builds, such an AQL request can be resource intensive.

Following the above, it is also possible to get a specific list of builds (for instance, based on the date they were deployed, a specific property, and more). For instance, this AQL query will return all the builds that were created after December 31st 2021:

builds.find({"created" : {"$gt" : "2021-12-31"}})

 

This AQL query will return all the builds that generated items with an Apache license:

builds.find({"module.artifact.item.@license":{"$match":"Apache*"}})

 

More on that can be found in the Entities and Fields section. 

The builds.json file should contain the builds list and should look similar to this:

{"results":[{"build.created":"2022-02-17T10:35:03.839Z","build.created_by":"admin","build.name":"new-pipeline","build.number":"38","build.repo":"artifactory-build-info","build.started":"2022-02-17T10:34:56.326Z","build.url":"http://localhost:8080/job/new-pipeline/38/"},{"build.created":"2022-02-17T10:36:24.418Z","build.created_by":"admin","build.name":"new-pipeline","build.number":"39","build.repo":"artifactory-build-info","build.started":"2022-02-17T10:36:17.398Z","build.url":"http://localhost:8080/job/new-pipeline/39/"},{"build.created":"2022-02-22T07:19:00.042Z","build.created_by":"admin","build.name":"new-pipeline","build.number":"40","build.repo":"artifactory-build-info","build.started":"2022-02-22T07:18:49.973Z","build.url":"http://localhost:8080/job/new-pipeline/40/"},
.
.
.
"build.started":"2022-02-22T08:20:15.765Z","build.url":"http://localhost:8080/job/test2/5/"}],"range":{"start_pos":0,"end_pos":19,"total":19}}