Jenkins - get latest artifact with curl

不问归期 提交于 2021-02-08 05:10:18

问题


I've been looking around and cannot find how to download the latest artifact with curl or even just to know the link.

I've discovered the permalinks and api xml/json feeds which contain all the data that is needed such as the artifact names etc....Also discovered the special link that zips all artifacts, but my artifact is already zipped.

Is there is a way to not have to pick out information and just use a simple link. In other words, tell jenkins to give me the latest artifact of job x without specifying filenames etc... such as:

jenkinsserver:8080/job/job_name/lastbuild/artifactdownload

Any help would be appreciated. Thank-you

EDIT: Should have mentioned that the name of the artifact contains the version number, such as: artifact.xx.xx.xx.zip


回答1:


Yes, there is an option to achieve this:

https://jenkinsserver.com/job/<job-name>/lastSuccessfulBuild/artifact/<Artifact-Name>



回答2:


You have to do a get on

http://localhost:9091/job/JOB_NAME/lastSuccessfulBuild/api/json

then you parse that looking for artifacts array then look at relativePath and do another get on the actual artifact

http://localhost:9091/job/JOB_NAME/lastSuccessfulBuild/artifact/WHAT_EVER_ARTIFACT




回答3:


I think most proper URL should be:

Current LTS stable https://updates.jenkins.io/stable/latestCore.txt

Current main branch: https://updates.jenkins.io/current/latestCore.txt



来源:https://stackoverflow.com/questions/29269922/jenkins-get-latest-artifact-with-curl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!