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

2

8

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?

Undis answered 10/3, 2016 at 15:32 Comment(0)
D
9

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

Dialytic answered 10/3, 2016 at 16:23 Comment(1)
i would also need to get artifact size. is it possible somehow ?Blurt
I
9

you can download created artifacts with curl:

curl -u "${USR}":"${PWD}" $JENKINS'/job/'"${NAM}"/"{$JOB}"'/artifact/*zip*/archive.zip' --output "${NAM}_{$JOB}_archive.zip"
Illogic answered 24/4, 2017 at 9:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.