jenkins api 使用

1.  java
  1. <dependency>
  2. <groupId>com.offbytwo.jenkins</groupId>
  3. <artifactId>jenkins-client</artifactId>
  4. <version>0.3.7</version>
  5. </dependency>
 
2. 代码
 
  1. final JenkinsServer jenkins =newJenkinsServer(new URI("http://XXXXX"),"XXXXX",
  2. "XXXXXXX");
  3. Map<String,Job> jobs = jenkins.getJobs();
  4. jobs.values().forEach(newConsumer<Job>(){
  5. publicvoid accept(final Job t){
  6. try{
  7. JobWithDetails info= jenkins.getJob(t.getName());
  8. // System.out.println(t.getName()+t.getUrl());
  9. System.out.println("构建历史"+info.getLastBuild().getNumber());
  10. info.getAllBuilds().forEach(newConsumer<Build>(){
  11. publicvoid accept(Build arg0){
  12. // TODO Auto-generated method stub
  13. System.out.println(arg0.getQueueId()+arg0.getNumber()+t.getName());
  14. }
  15. });
  16. }catch(IOException e){
  17. // TODO Auto-generated catch block
  18. e.printStackTrace();
  19. }
  20. // TODO Auto-generated method stub
  21. }
  22. });
 
   
   
 
 

posted on 2017-04-11 09:15  荣锋亮  阅读(696)  评论(0编辑  收藏  举报

导航