org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution Java Examples

The following examples show how to use org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuildQueueListener.java    From github-autostatus-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * Adds {@link BuildBlockedAction} action to blocked pipeline builds to keep
 * track of the time spent blocked.
 */
@Override
public void onEnterBlocked(Queue.BlockedItem item) {
    if (!(item.task instanceof ExecutorStepExecution.PlaceholderTask)) {
        return;
    }
    Run run = ((ExecutorStepExecution.PlaceholderTask) item.task).run();

    if (run != null) {
        run.addOrReplaceAction(new BuildBlockedAction(System.currentTimeMillis()));
    }
}
 
Example #2
Source File: BuildQueueListener.java    From github-autostatus-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onLeaveBlocked(Queue.BlockedItem item) {
    if (!(item.task instanceof ExecutorStepExecution.PlaceholderTask)) {
        return;
    }
    Run run = ((ExecutorStepExecution.PlaceholderTask) item.task).run();

    if (run != null) {
        BuildBlockedAction action = run.getAction(BuildBlockedAction.class);
        if (action != null) {
            action.setTimeReleased(System.currentTimeMillis());
        }
    }
}
 
Example #3
Source File: KubernetesPipelineTest.java    From kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
@Issue("JENKINS-49707")
@Test
public void terminatedPod() throws Exception {
    r.waitForMessage("+ sleep", b);
    deletePods(cloud.connect(), getLabels(this, name), false);
    r.assertBuildStatus(Result.ABORTED, r.waitForCompletion(b));
    r.waitForMessage(new ExecutorStepExecution.RemovedNodeCause().getShortDescription(), b);
}
 
Example #4
Source File: BuildQueueListenerTest.java    From github-autostatus-plugin with MIT License 4 votes vote down vote up
@Test
public void testEnterBlockedPlaceHolder() throws Exception {
    
    Run run = mock(Run.class);
    
    ExecutorStepExecution.PlaceholderTask task = mock(ExecutorStepExecution.PlaceholderTask.class);
    when(task.run()).thenReturn(run);

    BlockedItem item = mock(BlockedItem.class);
    
    setFinal(item, BlockedItem.class.getField("task"), task);

    BuildQueueListener buildQueueListener = new BuildQueueListener();
    
    buildQueueListener.onEnterBlocked(item);
    verify(run).addOrReplaceAction(any());    
}
 
Example #5
Source File: BuildQueueListenerTest.java    From github-autostatus-plugin with MIT License 4 votes vote down vote up
@Test
public void testLeaveBlockedUpdatesAction() throws Exception {
    
    Run run = mock(Run.class);
    BuildBlockedAction buildBlockedAction = mock(BuildBlockedAction.class);
    when(run.getAction(BuildBlockedAction.class)).thenReturn(buildBlockedAction);
    
    ExecutorStepExecution.PlaceholderTask task = mock(ExecutorStepExecution.PlaceholderTask.class);
    when(task.run()).thenReturn(run);

    BlockedItem item = mock(BlockedItem.class);
    
    setFinal(item, BlockedItem.class.getField("task"), task);

    BuildQueueListener buildQueueListener = new BuildQueueListener();
    
    buildQueueListener.onLeaveBlocked(item);
    verify(buildBlockedAction).setTimeReleased(anyLong());
}