diff --git a/src/main/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.java b/src/main/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.java
index f59ed082..2214db77 100644
--- a/src/main/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.java
+++ b/src/main/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.java
@@ -314,6 +314,11 @@ public String getId() throws AbortException {
return build().getId();
}
+ @Whitelisted
+ public String getExternalizableId() {
+ return externalizableId;
+ }
+
/**
* Get environment variables defined in the build.
*
diff --git a/src/main/resources/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper/help.html b/src/main/resources/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper/help.html
index 90ecf847..0c0a35ab 100644
--- a/src/main/resources/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper/help.html
+++ b/src/main/resources/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper/help.html
@@ -12,6 +12,7 @@
fullProjectName
Full name of the project of this build, including folders such as folder1/folder2/foo
.
description
additional information about the build
id
normally number
as a string
+ externalizableId
identifier for this build from combining fullProjectName
and number
as fullProjectName#number
timeInMillis
time since the epoch when the build was scheduled
startTimeInMillis
time since the epoch when the build started running
duration
duration of the build in milliseconds
diff --git a/src/test/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapperTest.java b/src/test/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapperTest.java
index 859fc466..9defe7ff 100644
--- a/src/test/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapperTest.java
+++ b/src/test/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapperTest.java
@@ -287,6 +287,17 @@ public void upstreamBuilds() throws Throwable {
});
}
+ @Test
+ @Issue("JENKINS-73421")
+ public void externalizableId() throws Throwable {
+ sessions.then(j -> {
+ WorkflowJob first = j.createProject(WorkflowJob.class, "first-job");
+ first.setDefinition(new CpsFlowDefinition("echo(/externalizableId=$currentBuild.externalizableId/)", true));
+ WorkflowRun firstRun = j.buildAndAssertSuccess(first);
+ j.assertLogContains("externalizableId=" + firstRun.getExternalizableId(), firstRun);
+ });
+ }
+
// Like org.hamcrest.text.MatchesPattern.matchesPattern(String) but doing a substring, not whole-string, match:
private static Matcher containsRegexp(final String rx) {
return new SubstringMatcher("containing the regexp", false, rx) {