提交 3d7985b5 编写于 作者: K kohsuke

added more convenience methods

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@34617 71c3de6d-444a-0410-be80-ed276b4c234a
上级 61c6e429
......@@ -25,6 +25,7 @@ package hudson.model.queue;
import hudson.model.Executor;
import hudson.model.Queue;
import hudson.model.Queue.Executable;
import hudson.model.Queue.Task;
/**
......@@ -44,7 +45,7 @@ public final class WorkUnit {
*/
public final WorkUnitContext context;
private Executor executor;
private volatile Executor executor;
WorkUnit(WorkUnitContext context, SubTask work) {
this.context = context;
......@@ -65,6 +66,13 @@ public final class WorkUnit {
executor = e;
}
/**
* If the execution has already started, return the current executable.
*/
public Executable getExecutable() {
return executor!=null ? executor.getCurrentExecutable() : null;
}
/**
* Is this work unit the "main work", which is the primary {@link SubTask}
* represented by {@link Task} itself.
......
......@@ -54,7 +54,7 @@ public class WideExecutionTest extends HudsonTestCase {
public void run() {
WorkUnitContext wuc = Executor.currentExecutor().getCurrentWorkUnit().context;
AbstractBuild b = (AbstractBuild)wuc.getPrimaryWorkUnit().getExecutor().getCurrentExecutable();
AbstractBuild b = (AbstractBuild)wuc.getPrimaryWorkUnit().getExecutable();
try {
b.setDescription("I was here");
} catch (IOException e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册