How to get corresponding build artifacts of a job in jenkins ?

怎甘沉沦 提交于 2020-01-03 17:21:14

问题


I create Jenkins jobs using hudson.cli.CLI jar. I have selected "Archive the artifacts" option in the "Post-build steps" section. It archives the artifacts on each succesfull build. I am using jenkins remote access api http://localhost:8080/job/job_name/api/json to get details about jobs. and http://localhost:8080/job/job_name/job_number/api/json to get details about builds.

When I delete a build corresponding archived artifacts are not deleted. I'd like to make sure that they are deleted.

When I use jenkins remote access api http://localhost:8080/job/[job_name]/[job_number]/api/json for a build, it returns json data which contains all previously archived artifacts (other successful builds artifacts) with this (running build) build artifact. How do I get related artifact of a build (a successful build should return its artifact, not all previous successfull artifacts). Any suggestions or ideas ?


回答1:


I suspect that you do not clean your workspace between the builds and archive all the artifacts that are found there, including those from previous builds.




回答2:


A build with no archived artifacts will have this json output:

"artifacts":[]

A build with archived artifacts will have this kind of json output:

"artifacts":[{"displayPath":"output","fileName":"output","relativePath":"output"}]

This artifact could be seen at http://localhost:8080/job/[job_name]/[job_number]/artifact/



来源:https://stackoverflow.com/questions/9431852/how-to-get-corresponding-build-artifacts-of-a-job-in-jenkins

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