https://github.com/jenkinsci/...
下载这个插件,cd到下载目录下,编译插件,
使用:mvn install 或者 mvn package命令。
编译完成后会在插件目录下生成target目录,可以看到
打开安装好的jenkins
上传刚编译好的 statistics-gatherer.hpi 插件安装。
打开系统设置。
会发现多了一个Statistics Gatherer模块
打开高级配置,将http勾选。
@RestController @RequestMapping(value = "/jenkins", produces = "application/json;charset=UTF-8") public class BuildDataController{ @RequestMapping("/buildData") public void buildData(HttpServletRequest request) throws IOException { BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "utf-8")); StringBuilder responseStrBuilder = new StringBuilder(); String inputStr; while ((inputStr = streamReader.readLine()) != null) { responseStrBuilder.append(inputStr); } BuildData build = JSON.parseObject(responseStrBuilder.toString(), BuildData.class); } } @Setter @Getter public class BuildData { private Date startTime; private Date endTime; private String startedUserName; private String fullJobName; private String jobName; private String result; private Integer id; private String buildCause; private String buildUrl; }
运行程序,在jenkins中Build URL填入接口地址。
构建jenkins项目,就可以获得了jenkins build数据。
同理可以获取Queue、Project/Job、Build Steps数据,返还的数据具体格式可以去 https://github.com/jenkinsci/... 查看。