diff --git a/core/src/main/java/jenkins/model/CoreEnvironmentContributor.java b/core/src/main/java/jenkins/model/CoreEnvironmentContributor.java
index 86ba69eb58d8..c89833dd0d89 100644
--- a/core/src/main/java/jenkins/model/CoreEnvironmentContributor.java
+++ b/core/src/main/java/jenkins/model/CoreEnvironmentContributor.java
@@ -65,6 +65,7 @@ public void buildEnvironmentFor(Job j, EnvVars env, TaskListener listener) throw
Node n = e.getOwner().getNode();
if (n != null)
env.put("NODE_LABELS", Util.join(n.getAssignedLabels(), " "));
+ env.put("EXECUTOR_COUNT", String.valueOf(e.getOwner().countExecutors()));
}
}
}
diff --git a/core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.groovy b/core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.groovy
index 31cdf2c1ff7b..54550c05767d 100644
--- a/core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.groovy
+++ b/core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.groovy
@@ -3,7 +3,7 @@ package jenkins.model.CoreEnvironmentContributor;
def l = namespace(lib.JenkinsTagLib)
// also advertises those contributed by Run.getCharacteristicEnvVars()
-["BUILD_NUMBER","BUILD_ID","BUILD_DISPLAY_NAME","JOB_NAME", "JOB_BASE_NAME","BUILD_TAG","EXECUTOR_NUMBER","NODE_NAME","NODE_LABELS","WORKSPACE","JENKINS_HOME","JENKINS_URL","BUILD_URL","JOB_URL"].each { name ->
+["BUILD_NUMBER","BUILD_ID","BUILD_DISPLAY_NAME","JOB_NAME", "JOB_BASE_NAME","BUILD_TAG","EXECUTOR_COUNT","EXECUTOR_NUMBER","NODE_NAME","NODE_LABELS","WORKSPACE","JENKINS_HOME","JENKINS_URL","BUILD_URL","JOB_URL"].each { name ->
l.buildEnvVar(name:name) {
raw(_("${name}.blurb"))
}
diff --git a/core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.properties b/core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.properties
index b24437881560..86e4b16f9422 100644
--- a/core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.properties
+++ b/core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.properties
@@ -4,6 +4,7 @@ BUILD_DISPLAY_NAME.blurb=The display name of the current build, which is somethi
JOB_NAME.blurb=Name of the project of this build, such as "foo" or "foo/bar".
JOB_BASE_NAME.blurb=Short Name of the project of this build stripping off folder paths, such as "foo" for "bar/foo".
BUILD_TAG.blurb=String of "jenkins-$'{'JOB_NAME}-$'{'BUILD_NUMBER}". All forward slashes ("/") in the JOB_NAME are replaced with dashes ("-"). Convenient to put into a resource file, a jar file, etc for easier identification.
+EXECUTOR_COUNT.blurb=Number of executors available on currently running node
EXECUTOR_NUMBER.blurb=\
The unique number that identifies the current executor \
(among executors of the same machine) that\u2019s \