[JIRA] (JENKINS-58924) job.allBuilds points to wrong URL when called from a job inside a folderJob

2019-08-14 Thread niclas.lindb...@nillsoft.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Niclas Lindberg updated an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-58924  
 
 
  job.allBuilds points to wrong URL when called from a job inside a folderJob   
 

  
 
 
 
 

 
Change By: 
 Niclas Lindberg  
 

  
 
 
 
 

 
 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[i] = EncodingUtils.encode(nameParts[i]);   }   return "/job/" + String.join("/job/",nameParts);}public List getAllBuilds() throws IOException {   String path = getJobPath();   try {      List builds = client.get(path + "?tree=allBuilds[number[*],url[*],queueId[*]]", AllBuilds.class).getAllBuilds();      if (builds == null) {          return Collections.emptyList();      } else {         return transform(builds, new Function() {            @Override            public Build apply(Build from) {               return buildWithClient(from);           }        });      }   } catch (HttpResponseException e) {              // TODO: Thinks about a better handling if the job does not exist?         if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {            // TODO: Check this if this is necessary or a good idea?           return null;        }        throw e;   }}  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)  
 

[JIRA] (JENKINS-58924) job.allBuilds points to wrong URL when called from a job inside a folderJob

2019-08-14 Thread niclas.lindb...@nillsoft.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Niclas Lindberg created an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-58924  
 
 
  job.allBuilds points to wrong URL when called from a job inside a folderJob   
 

  
 
 
 
 

 
Issue Type: 
  Bug  
 
 
Assignee: 
 Karl-Heinz Marbaise  
 
 
Components: 
 java-client-api  
 
 
Created: 
 2019-08-14 11:36  
 
 
Priority: 
  Critical  
 
 
Reporter: 
 Niclas Lindberg  
 

  
 
 
 
 

 
 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  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment