Skip to content

Commit

Permalink
Fix Build-Info URL (#158)
Browse files Browse the repository at this point in the history

Co-authored-by: eyalbe4 <[email protected]>
  • Loading branch information
eyalbe4 and eyalb4doc authored Dec 28, 2024
1 parent c15f10d commit 53cb597
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install Java
uses: actions/setup-java@v3
with:
java-version: "8"
java-version: "11.0.25+9"
distribution: "temurin"

- name: Run tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@ public void runnerFinished(@NotNull BuildRunnerContext runner, @NotNull BuildFin
}
}

private static void addBuildInfoUrlParam(BuildRunnerContext runner) {
private static void addBuildInfoUrlParam(BuildRunnerContext runner) {
String artifactoryUrl = StringUtils.removeEnd(runner.getRunnerParameters().get(RunnerParameterKeys.URL), "/");

String buildInfoUrl;
if (StringUtils.endsWith(artifactoryUrl, "/artifactory")) {
// Here we can deduce the platform URL
buildInfoUrl = BuildInfoExtractorUtils.createBuildInfoUrl(StringUtils.removeEnd(artifactoryUrl, "/artifactory"),
runner.getRunnerParameters().get(BUILD_NAME), runner.getBuild().getBuildNumber(), "", "", false, true);
buildInfoUrl = createBuildInfoUrl(StringUtils.removeEnd(artifactoryUrl, "/artifactory"), (String)runner.getRunnerParameters().get(BUILD_NAME), runner.getBuild().getBuildNumber(), (String)runner.getRunnerParameters().get("org.jfrog.artifactory.build.timestamp"));
} else {
// Without the platform URL it would work only on Artifactory 6
buildInfoUrl = BuildInfoExtractorUtils.createBuildInfoUrl(artifactoryUrl, runner.getRunnerParameters().get(BUILD_NAME),
runner.getBuild().getBuildNumber(), "", "", false, false);
}

runner.getBuild().addSharedSystemProperty(BUILD_URL + "." + runner.getBuild().getBuildId() + "." + runner.getId(), buildInfoUrl);
}
}

private static String createBuildInfoUrl(String platformUrl, String buildName, String buildNumber, String timeStamp) {
String timestampUrlPart = StringUtils.isBlank(timeStamp) ? "" : "/" + timeStamp;
return String.format("%s/%s/%s%s/%s", platformUrl + "/ui/builds", buildName, buildNumber, timestampUrlPart, "published");
}
}

0 comments on commit 53cb597

Please sign in to comment.