Open BriandUlysse opened 6 years ago
You're welcome... Can you give an code example? But I fear that this is not implemented currently (maybe it's not possible to get via REST API from Jenkins)...
It's hard to give a concrete example since it's something for the Job object in general.
By using the json API of jenkins on a job example : http://MyServerAdress/job/MyJob/api/json
I can see :
color : blue
healthReport : 0 : description : .... IconClassName :.... IconUrl : .... score :....
But with my Job object in java, It dosn't seem to be possible to access to those informations with the library, even with the method details() .
Hello all,
I met the same situtation. I also want to get the color . I get the color to check the job is still running or not. is there another way for me to check the job still running???
for python api I can get the color value.
def GetAllJobRunningNumber(self,):
queue_number_D = {}
allqueue = self.get_queue_info()
for queue in allqueue:
jobname = queue['task']['name']
if queue_number_D.has_key(jobname):
queue_number_D[jobname] += 1
else:
queue_number_D.setdefault(jobname, 1)
alljobs = self.get_jobs(view_name=self.view_name)
running_number_D = {}
for job in alljobs:
color, jobname = job['color'],job['name']
if "anime" in color and "disabled" not in color:
queuenum = queue_number_D.get(jobname, 0)
running_number_D.setdefault(jobname, 1 + queuenum)
elif "disabled" in color :
running_number_D.setdefault(jobname, -1)
else:
queuenum = queue_number_D.get(jobname, 0)
if queuenum > 0:
running_number_D.setdefault(jobname, -1)
else:
running_number_D.setdefault(jobname, 0)
return running_number_D
for my workaround: i write a class JobDetails extends JobWithDetails then client.get(job.getUrl(), JobDetails.class);
public class JobDetails extends JobWithDetails {
private String color;
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
}
Map<String, Job> jobs = server.getJobs(viewName);
for (Map.Entry<String, Job> entry : jobs.entrySet()) {
Job job = entry.getValue();
JobDetails details = client.get(job.getUrl(), JobDetails.class);
String name = job.getName();
boolean buildable = details.isBuildable(); //这个判断job是否被禁用。
boolean running = details.hasLastBuildRun();
System.out.println(details.getColor());
}
Hello,
Firstly, thank you for your work, this project is really useful, but I have a few problems.
I have an object Job and I want to get the color(red, red_animated, etc...) but I can't find anything in the Job methods. Is there a way to access to it, or it's not implemented for now? Reffering to the Json architecture it should be directly in the Job Same problem for the healthReport.
Thank you for your help.