-
Bug
-
Resolution: Unresolved
-
Critical
-
None
When a job is residing in a folderJob then the API url to the job in job.allBuilds() points to /job/SIMPLE_JOB_NAME/api/json which causes a 404. Instead the job.allBuilds() should point to /job/FOLDER_JOB_NAME/job/SIMPLE_JOB_NAME/api/json.
Code: JobWithDetails#127
Fix:
private String getJobPath() {
String[] nameParts = this.getFullName().split("
/");
for(int i=0;i<nameParts.length;i++)
return "/job/" + String.join("/job/",nameParts);
}
public List<Build> getAllBuilds() throws IOException {
String path = getJobPath();
try {
List<Build> builds = client.get(path + "?tree=allBuilds[number[*],url[*],queueId[*]]", AllBuilds.class).getAllBuilds();
if (builds == null)
{ return Collections.emptyList(); } else {
return transform(builds, new Function<Build, Build>() {
@Override
public Build apply(Build from)
});
}
} catch (HttpResponseException e) {
// TODO: Thinks about a better handling if the job does not exist?
if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND)
throw e;
}
}