jenkinsci / java-client-api

A Jenkins API client for Java
MIT License
896 stars 468 forks source link

JobWithDetails.getAllBuilds() throws Exception with 404 #490

Open WangFeiwu opened 2 years ago

WangFeiwu commented 2 years ago

My job has many builds, but I got null when call jenkinsServer.getJob("Folder1/Folder2/jobName").getAllBuilds().

Then I check the source code, and find:

List<Build> builds = client.get(path + "job/" + EncodingUtils.encode(this.getName())
                    + "?tree=allBuilds[number[*],url[*],queueId[*]]", AllBuilds.class).getAllBuilds();

The problem is this.getName(). My job's full path is : /job/Folder1/job/Folder2/job/jobName

But this.getName() only returns jobName.

So I can get correct results with this:

List<Build> builds = client.get("/job/Folder1/job/Folder2/job/jobName"
                    + "?tree=allBuilds[number[*],url[*],queueId[*]]", AllBuilds.class).getAllBuilds();
Volcanolcc commented 2 years ago

I have the same problem, do you have any good solution?

Natsukashiiteja commented 10 months ago

we can define our current jobs path in a static or a final variable before instantiating the this.getName(). Once try this approach