Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 402
Kenny Basuki Avatar asked Mar 10 '16 15:03

Kenny Basuki


People also ask

How do I download Jenkins artifacts?

(Required) Select the service connection for your Jenkins instance. To create one, click the Manage link and create a new Jenkins service connection. (Required) The name of the Jenkins job to download artifacts from. This must exactly match the job name on the Jenkins server.

What is Jenkins REST API?

The jenkins-rest library is an object oriented Java project that provides access to the Jenkins REST API programmatically to some remote API Jenkins provides. It is built using the jclouds toolkit and can easily be extended to support more REST endpoints.

Can we call an API from Jenkins?

Now we will create the URL for the request. 2. If you do not have an API key, click on Create API Key; now, we can copy it for further use in our Jenkins Project. 3. After we have the API Key, we press on API Documentation.


2 Answers

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

like image 146
Bruno Lavit Avatar answered Sep 20 '22 13:09

Bruno Lavit


you can download created artifacts with curl:

curl -u "${USR}":"${PWD}" $JENKINS'/job/'"${NAM}"/"{$JOB}"'/artifact/*zip*/archive.zip' --output "${NAM}_{$JOB}_archive.zip"
like image 33
lolo Avatar answered Sep 20 '22 13:09

lolo