提交 31d4e48d 编写于 作者: K kohsuke

implemented EXECUTOR_NUMBER variable.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1112 71c3de6d-444a-0410-be80-ed276b4c234a
上级 5543c771
......@@ -20,10 +20,16 @@ public class Executor extends Thread {
private long startTime;
/**
* Executor number that identifies it among other executors for the same {@link Computer}.
*/
private int number;
public Executor(Computer owner) {
super("Executor #"+owner.getExecutors().size()+" for "+owner.getDisplayName());
this.owner = owner;
this.queue = Hudson.getInstance().getQueue();
this.number = owner.getExecutors().size();
start();
}
......@@ -72,6 +78,17 @@ public class Executor extends Thread {
return build;
}
/**
* Gets the executor number that uniquely identifies it among
* other {@link Executor}s for the same computer.
*
* @return
* a sequential number starting from 0.
*/
public int getNumber() {
return number;
}
/**
* Returns true if this {@link Executor} is ready for action.
*/
......
......@@ -787,6 +787,13 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
env.put("BUILD_ID",getId());
env.put("BUILD_TAG","hudson-"+getParent().getName()+"-"+number);
env.put("JOB_NAME",getParent().getName());
Thread t = Thread.currentThread();
if (t instanceof Executor) {
Executor e = (Executor) t;
env.put("EXECUTOR_NUMBER",String.valueOf(e.getNumber()));
}
return env;
}
......
......@@ -21,6 +21,12 @@
<dt>BUILD_TAG</dt>
<dd>String of "hudson-<i>${JOBNAME}</i>-<i>${BUILD_NUMBER}</i>". Convenient to put into
a resource file, a jar file, etc for easier identification.</dd>
<dt>EXECUTOR_NUMBER</dt>
<dd>The unique number that identifies the current executor
(among executors of the same machine) that's
carrying out this build. This is the number you see in
the "build executor status", except that the number starts from 0, not 1.</dd>
</dl>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册