public ConsoleLog getConsoleOutputText ( int bufferOffset , boolean crumbFlag ) throws IOException { List < NameValuePair > formData = new ArrayList <> ( ) ; formData . add ( new BasicNameValuePair ( "start" , Integer . toString ( bufferOffset ) ) ) ; String path = getUrl ( ) + "logText/progressiveText" ; HttpResponse httpResponse = client . post_form_with_result ( path , formData , crumbFlag ) ; Header moreDataHeader = httpResponse . getFirstHeader ( MORE_DATA_HEADER ) ; Header textSizeHeader = httpResponse . getFirstHeader ( TEXT_SIZE_HEADER ) ; String response = EntityUtils . toString ( httpResponse . getEntity ( ) ) ; boolean hasMoreData = false ; if ( moreDataHeader != null ) { hasMoreData = Boolean . TRUE . toString ( ) . equals ( moreDataHeader . getValue ( ) ) ; } Integer currentBufferSize = bufferOffset ; if ( textSizeHeader != null ) { try { currentBufferSize = Integer . parseInt ( textSizeHeader . getValue ( ) ) ; } catch ( NumberFormatException e ) { LOGGER . warn ( "Cannot parse buffer size for job {0} build {1}. Using current offset!" , this . getDisplayName ( ) , this . getNumber ( ) ) ; } } return new ConsoleLog ( response , hasMoreData , currentBufferSize ) ; }
Get build console output log as text . Use this method to periodically obtain logs from jenkins and skip chunks that were already received