Skip to content

Commit b619968

Browse files
Added EXECUTOR_COUNT to environment variables
jenkinsci/workflow-durable-task-step-plugin#106 Signed-off-by: Artur Harasimiuk <[email protected]>
1 parent aa2eeb8 commit b619968

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

core/src/main/java/jenkins/model/CoreEnvironmentContributor.java

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void buildEnvironmentFor(Job j, EnvVars env, TaskListener listener) throw
6565
Node n = e.getOwner().getNode();
6666
if (n != null)
6767
env.put("NODE_LABELS", Util.join(n.getAssignedLabels(), " "));
68+
env.put("EXECUTOR_COUNT", String.valueOf(e.getOwner().countExecutors()));
6869
}
6970
}
7071
}

core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package jenkins.model.CoreEnvironmentContributor;
33
def l = namespace(lib.JenkinsTagLib)
44

55
// also advertises those contributed by Run.getCharacteristicEnvVars()
6-
["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 ->
6+
["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 ->
77
l.buildEnvVar(name:name) {
88
raw(_("${name}.blurb"))
99
}

core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.properties

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ BUILD_DISPLAY_NAME.blurb=The display name of the current build, which is somethi
44
JOB_NAME.blurb=Name of the project of this build, such as "foo" or "foo/bar".
55
JOB_BASE_NAME.blurb=Short Name of the project of this build stripping off folder paths, such as "foo" for "bar/foo".
66
BUILD_TAG.blurb=String of "jenkins-<i>$'{'JOB_NAME}</i>-<i>$'{'BUILD_NUMBER}</i>". 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.
7+
EXECUTOR_COUNT.blurb=Number of executors available on currently running node
78
EXECUTOR_NUMBER.blurb=\
89
The unique number that identifies the current executor \
910
(among executors of the same machine) that\u2019s \

0 commit comments

Comments
 (0)