Is there any Jenkins API to get artifacts name and download it?

Kenny Basuki picture Kenny Basuki · Mar 10, 2016 · Viewed 15.7k times · Source

I want to ask, If I use jenkins. How can I get all artifacts list and download it, but not from jenkins web interface. I want to make my own web interface for certain goals.

Is there any jenkins API to do this?

Answer

Bruno Lavit picture Bruno Lavit · Mar 10, 2016

According to this answer: https://superuser.com/questions/587426/download-a-file-from-the-latest-stable-jenkins-build

You can use the Jenkins API to get the list of artifacts: http://your.jenkins.server/job/your.job/lastStableBuild/api/xml?tree=artifacts%5BrelativePath%5D

With a script, you can extract the artefact relative path:

enter image description here

Next, you can build your download URLs like: http://your.jenkins.server/job/your.job/lastStableBuild/artifact/relativePath