Skip to content

Commit fbde7ba

Browse files
authored
Merge pull request #46 from asambstack/master
Update separator check to accomodate builds without separator in names
2 parents 6ee9073 + 5759507 commit fbde7ba

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111

1212
<artifactId>browserstack-integration</artifactId>
13-
<version>1.2.3-SNAPSHOT</version>
13+
<version>1.2.4-SNAPSHOT</version>
1414
<packaging>hpi</packaging>
1515

1616
<name>BrowserStack</name>

src/main/java/com/browserstack/automate/ci/jenkins/BrowserStackCypressReportForBuild.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public JSONObject getCypressMatrix(String filepath) {
5252
String jsonTxt = IOUtils.toString(is, "UTF-8");
5353
report = new JSONObject(jsonTxt);
5454
} catch (FileNotFoundException e) {
55-
logError(logger, "No BrowserStackBuildAction found");
55+
logError(logger, "Cypress report not found at " + reportJSONPath);
5656
tracker.sendError("BrowserStack Cypress Report Not Found", pipelineStatus, "CypressReportGeneration");
5757
} catch (IOException e) {
5858
logError(logger, "There was a problem while reading report files");
@@ -70,7 +70,9 @@ public boolean generateBrowserStackCypressReport(String workspace) {
7070
}
7171

7272
String buildNameWithBuildNumber = matrix.optString("build_name");
73-
String buildNameWithoutBuildNumber = buildNameWithBuildNumber.substring(0, buildNameWithBuildNumber.lastIndexOf(": "));
73+
int indexOfBuildNumberSeparator = buildNameWithBuildNumber.lastIndexOf(": ") == -1 ? buildNameWithBuildNumber.length()
74+
: buildNameWithBuildNumber.lastIndexOf(": ");
75+
String buildNameWithoutBuildNumber = buildNameWithBuildNumber.substring(0, indexOfBuildNumberSeparator);
7476

7577
if (buildNameWithoutBuildNumber == null) {
7678
logError(logger, "BrowserStack Cypress Report not generated, result json may have been corrupted. Please retry.");

src/main/java/com/browserstack/automate/ci/jenkins/BrowserStackCypressReportPublisher.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace, @Nonn
4747
final EnvVars parentEnvs = build.getEnvironment(listener);
4848
String browserStackBuildName = parentEnvs.get(BrowserStackEnvVars.BROWSERSTACK_BUILD_NAME);
4949
browserStackBuildName = Optional.ofNullable(browserStackBuildName).orElse(parentEnvs.get(Constants.JENKINS_BUILD_TAG));
50-
final String jenkinsFolder = parentEnvs.get("WORKSPACE");
50+
final String jenkinsFolder = parentEnvs.get("BROWSERSTACK_CYPRESS_PROJECT_ROOT") != null ? parentEnvs.get("BROWSERSTACK_CYPRESS_PROJECT_ROOT") : parentEnvs.get("WORKSPACE");
5151
ProjectType product = ProjectType.AUTOMATE;
5252

5353
tracker.reportGenerationInitialized(browserStackBuildName, product.name(), pipelineStatus);

0 commit comments

Comments
 (0)