Skip to content

Commit

Permalink
Merge pull request #182 from gradle/cj/jenkins-url
Browse files Browse the repository at this point in the history
Capture Jenkins/Hudson urls to differentiate builds by controller
  • Loading branch information
clayburn authored Dec 5, 2023
2 parents a9e0bc2 + 3bbdf77 commit f3e862f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/com/gradle/CustomBuildScanEnhancements.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@ public CaptureCiMetadataAction(BuildScanApi buildScan) {

private void execute() {
if (isJenkins() || isHudson()) {
String controllerUrlEnvVar = isJenkins() ? "JENKINS_URL" : "HUDSON_URL";

Optional<String> buildUrl = envVariable("BUILD_URL");
Optional<String> buildNumber = envVariable("BUILD_NUMBER");
Optional<String> nodeName = envVariable("NODE_NAME");
Optional<String> jobName = envVariable("JOB_NAME");
Optional<String> stageName = envVariable("STAGE_NAME");
Optional<String> controllerUrl = envVariable(controllerUrlEnvVar);

buildUrl.ifPresent(url ->
buildScan.link(isJenkins() ? "Jenkins build" : "Hudson build", url));
Expand All @@ -159,6 +162,8 @@ private void execute() {
addCustomValueAndSearchLink(buildScan, "CI job", value));
stageName.ifPresent(value ->
addCustomValueAndSearchLink(buildScan, "CI stage", value));
controllerUrl.ifPresent(value ->
buildScan.value("CI controller", value));

jobName.ifPresent(j -> buildNumber.ifPresent(b -> {
Map<String, String> params = new LinkedHashMap<>();
Expand Down

0 comments on commit f3e862f

Please sign in to comment.