com.liferay.jenkins.results.parser.JenkinsConsoleTextLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.jenkins.results.parser
Show all versions of com.liferay.jenkins.results.parser
Liferay Jenkins Results Parser
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.jenkins.results.parser;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringEscapeUtils;
/**
* @author Peter Yoo
*/
public class JenkinsConsoleTextLoader {
public JenkinsConsoleTextLoader(String buildURL) {
this(buildURL, false);
}
public JenkinsConsoleTextLoader(
String buildURL, boolean bypassConsoleLogSizeLimit) {
this.buildURL = JenkinsResultsParserUtil.getLocalURL(buildURL);
this.bypassConsoleLogSizeLimit = bypassConsoleLogSizeLimit;
consoleLogFileKey = JenkinsResultsParserUtil.combine(
"jenkins_console_log-", String.valueOf(buildURL.hashCode()),
".log");
JenkinsResultsParserUtil.saveToCacheFile(consoleLogFileKey, "");
serverLogSize = 0;
}
public String getConsoleText() {
if (buildURL.startsWith("file:") || buildURL.contains("mirrors")) {
try {
return JenkinsResultsParserUtil.toString(
buildURL + "/consoleText", false, true);
}
catch (IOException ioException) {
throw new RuntimeException(ioException);
}
}
update();
String consoleText = JenkinsResultsParserUtil.getCachedText(
consoleLogFileKey);
if (truncated) {
consoleText = consoleText + "\n[TRUNCATED]";
}
return consoleText;
}
public int getLineCount() {
String consoleLog = getConsoleText();
String[] consoleLogLines = consoleLog.split("\n");
return consoleLogLines.length;
}
public boolean hasMoreData() {
return hasMoreData;
}
protected synchronized void update() {
Retryable