Jenkins REST API to get job and job console log

后端 未结 4 1421
日久生厌
日久生厌 2021-02-10 03:18

How to get the details of the job along with it console output using Jenkins REST API

example of builds

console output:

I am using foll

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-10 03:43

    we can get console log with Above URL mentioned http://localhost:8080/job/Echo/25//consoleText

    URL urls = new URL("http://localhost:8080/job/Echo/25//consoleText"); 
    HttpURLConnection connection = (HttpURLConnection) urls.openConnection(); 
    connection.setDoOutput(true); 
    //connection.setRequestProperty("User-Agent", "Mozilla/5.0");
    connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.29 Safari/537.36");
    
    System.setProperty("http.agent", "Chrome");
    connection.setInstanceFollowRedirects(false); 
    connection.setRequestMethod("GET"); 
    connection.setRequestProperty("Content-Type", "application/json");
    
    // Convert to a JSON object to print data
    /*HttpServletRequest request;*/
    BufferedReader br = new BufferedReader(new InputStreamReader(
            (connection.getInputStream())));
    

    it worked for me if any queries please ping me

提交回复
热议问题