use of hudson.tasks.BuildStepMonitor in project jenkins by jenkinsci.
the class AbstractBuildTest method workspaceLock.
@Test
@Issue("JENKINS-10615")
public void workspaceLock() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
p.setConcurrentBuild(true);
OneShotEvent e1 = new OneShotEvent();
OneShotEvent e2 = new OneShotEvent();
OneShotEvent done = new OneShotEvent();
p.getPublishersList().add(new Recorder() {
@Override
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.NONE;
}
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException {
if (build.number == 1) {
// signal that build #1 is in publisher
e1.signal();
} else if (build.number == 2) {
// signal that build #2 is in publisher
e2.signal();
} else {
throw new IllegalArgumentException("unexpected build number: " + build.number);
}
done.block();
return true;
}
private Object writeReplace() {
return new Object();
}
});
QueueTaskFuture<FreeStyleBuild> b1 = p.scheduleBuild2(0);
e1.block();
QueueTaskFuture<FreeStyleBuild> b2 = p.scheduleBuild2(0);
e2.block();
// at this point both builds are in the publisher, so we verify that
// the workspace are differently allocated
assertNotEquals(b1.getStartCondition().get().getWorkspace(), b2.getStartCondition().get().getWorkspace());
done.signal();
}
Aggregations