-2

Is there any way to get artifact details such as timestamp, size and name from rest api, or any groovy script that we can place in task which will list timestamp, size and name and save to as json.

I want to display artifact size, timestamp & name component, search and asset doesn't give any specific details, any groovy or shell script that can capture all the details. Or we can add our own api or groovy to nexus3

Please help me here.

regards, SAMURAI

Samurai
  • 121
  • 1
  • 4
  • 15

1 Answers1

2

assets list gives you the downloadUrl where the file is located

you can make http HEAD request to get all headers including size and date

for example this command

curl -I -v https://repo1.maven.org/maven2/commons-io/commons-io/2.8.0/commons-io-2.8.0-javadoc.jar

prints:

....
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Length: 1138955
< ETag: "f9962ba4adc0193d474f4006872713b7"
< Content-Type: application/java-archive
< Last-Modified: Sun, 06 Sep 2020 13:55:02 GMT
< X-Checksum-MD5: f9962ba4adc0193d474f4006872713b7
< X-Checksum-SHA1: 1754c67b623e5df978230fab077602b51a7e5b0e
< Via: 1.1 varnish, 1.1 varnish
< Accept-Ranges: bytes
< Date: Mon, 09 Nov 2020 19:00:20 GMT
< Age: 10256
< X-Served-By: cache-bwi5140-BWI, cache-bos4634-BOS
< X-Cache: HIT, HIT
< X-Cache-Hits: 1, 1
< X-Timer: S1604948421.582954,VS0,VE2

where you have headers: Content-Length - size and Last-Modified - date.

daggett
  • 26,404
  • 3
  • 40
  • 56