Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<artifactId>browserstack-integration</artifactId>
<version>1.2.22-SNAPSHOT</version>
<version>1.2.23-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>BrowserStack</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@
import okhttp3.*;

import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import static com.browserstack.automate.ci.common.logger.PluginLogger.log;
import static com.browserstack.automate.ci.common.logger.PluginLogger.logError;

public class BrowserStackTestReportAction implements Action {

private static final String DEFAULT_REPORT_TIMEOUT = "120";
Expand All @@ -31,8 +27,6 @@ public class BrowserStackTestReportAction implements Action {
private static final String RATE_LIMIT = "RATE_LIMIT";
private static final String TEST_AVAILABLE = "TEST_AVAILABLE";
private static final int MAX_ATTEMPTS = 3;

private final transient PrintStream logger;
private final RequestsUtil requestsUtil;
private final BrowserStackCredentials credentials;
private final String buildName;
Expand All @@ -44,12 +38,11 @@ public class BrowserStackTestReportAction implements Action {
private String reportStatus;
private int maxRetryReportAttempt;

public BrowserStackTestReportAction(Run<?, ?> run, BrowserStackCredentials credentials, String buildName, String buildCreatedAt, final PrintStream logger) {
public BrowserStackTestReportAction(Run<?, ?> run, BrowserStackCredentials credentials, String buildName, String buildCreatedAt) {
this.run = run;
this.credentials = credentials;
this.buildName = buildName;
this.buildCreatedAt = buildCreatedAt;
this.logger = logger;
this.requestsUtil = new RequestsUtil();
this.reportHtml = null;
this.reportStyle = "";
Expand Down Expand Up @@ -82,7 +75,6 @@ private void fetchReport() {
String reportUrl = Constants.CAD_BASE_URL + Constants.BROWSERSTACK_CONFIG_DETAILS_ENDPOINT;

try {
log(logger, "Fetching BrowserStack report...");
Response response = requestsUtil.makeRequest(reportUrl, credentials, createRequestBody(params));
handleResponse(response);
} catch (Exception e) {
Expand Down Expand Up @@ -119,7 +111,6 @@ private void handleResponse(Response response) throws Exception {
reportStatus = RATE_LIMIT;
} else {
reportStatus = REPORT_FAILED;
logError(logger, "Non-success response while fetching report: " + response.code());
}
}
}
Expand Down Expand Up @@ -163,7 +154,7 @@ private void setReportSuccess(JSONObject report) {
ArtifactArchiver artifactArchiver = getArtifactArchiver(workspace, fullHtml);
artifactArchiver.perform(run, workspace, new EnvVars(), null, TaskListener.NULL);
} catch (Exception e) {
logError(logger, "Failed to save or archive report artifact: " + e.getMessage());
//do nothing, as we don't want to fail the build if archiving fails
}
}

Expand All @@ -188,7 +179,6 @@ private void handleFetchException(Exception e) {
if (maxRetryReportAttempt < 0) {
reportStatus = REPORT_FAILED;
}
logError(logger, "Exception while fetching the report: " + Arrays.toString(e.getStackTrace()));
}

public boolean isReportInProgress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void perform(Run<?, ?> build, @NonNull FilePath workspace, @NonNull Launc

String buildCreatedAt = String.valueOf(unixTimestamp);

build.addAction(new BrowserStackTestReportAction(build, credentials, browserStackBuildName,buildCreatedAt, logger));
build.addAction(new BrowserStackTestReportAction(build, credentials, browserStackBuildName,buildCreatedAt));

}

Expand Down