jenkins api 使用
1. java
<dependency>
<groupId>com.offbytwo.jenkins</groupId>
<artifactId>jenkins-client</artifactId>
<version>0.3.7</version>
</dependency>
2. 代码
final JenkinsServer jenkins =newJenkinsServer(new URI("http://XXXXX"),"XXXXX",
"XXXXXXX");
Map<String,Job> jobs = jenkins.getJobs();
jobs.values().forEach(newConsumer<Job>(){
publicvoid accept(final Job t){
try{
JobWithDetails info= jenkins.getJob(t.getName());
// System.out.println(t.getName()+t.getUrl());
System.out.println("构建历史"+info.getLastBuild().getNumber());
info.getAllBuilds().forEach(newConsumer<Build>(){
publicvoid accept(Build arg0){
// TODO Auto-generated method stub
System.out.println(arg0.getQueueId()+arg0.getNumber()+t.getName());
}
});
}catch(IOException e){
// TODO Auto-generated catch block
e.printStackTrace();
}
// TODO Auto-generated method stub
}
});