码迷,mamicode.com
首页 > 其他好文 > 详细

retrieve jenkins console output

时间:2016-12-29 20:00:44      阅读:365      评论:0      收藏:0      [点我收藏+]

标签:tostring   body   time   end   uil   getting   stringbu   ble   exception   

@Api(value = "console", description = "Retrieve the Console Outputs",produces=MediaType.APPLICATION_JSON_VALUE)
@Controller
public class ConsoleController {

@RequestMapping(value = "/consoleLogs/{job}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Getting jenkins console outputs", notes = "Getting jenkins console outputs")
@ResponseBody public String getConsoleOutputs(@ApiParam(value="url",required=true)@PathVariable(value = "job") String job)
throws Exception {
StringBuilder result = new StringBuilder();
URL url = new URL("http://localhost:8080/job/"+job+"/lastBuild/logText/progressiveText?start=0");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(30000);
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
result.append(line);
}
rd.close();
return result.toString();
}

}

retrieve jenkins console output

标签:tostring   body   time   end   uil   getting   stringbu   ble   exception   

原文地址:http://www.cnblogs.com/goldengallo/p/6234566.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!