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?
(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.
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.
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.
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:
Next, you can build your download URLs like: http://your.jenkins.server/job/your.job/lastStableBuild/artifact/relativePath
you can download created artifacts with curl
:
curl -u "${USR}":"${PWD}" $JENKINS'/job/'"${NAM}"/"{$JOB}"'/artifact/*zip*/archive.zip' --output "${NAM}_{$JOB}_archive.zip"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With