@Override
    public void build(final DefaultGoPublisher publisher,
                      final EnvironmentVariableContext environmentVariableContext, TaskExtension taskExtension, ArtifactExtension artifactExtension, PluginRequestProcessorRegistry pluginRequestProcessorRegistry, Charset consoleLogCharset) {
        ExecutionResult executionResult = null;
        try {
            executionResult = taskExtension.execute(pluginId, (task, pluginDescriptor) -> executeTask(task, publisher, environmentVariableContext, consoleLogCharset));
        } catch (Exception e) {
            logException(publisher, e);
        } finally {
            JobConsoleLoggerInternal.unsetContext();
        }
        if (executionResult == null) {
            logError(publisher, "ExecutionResult cannot be null. Please return a success or a failure response.");
        } else if (!executionResult.isSuccessful()) {
            logError(publisher, executionResult.getMessagesForDisplay());
        }
    }
@Test
    public void shouldRegisterTaskConfigDuringExecutionAndUnregisterOnSuccessfulCompletion() {
        final PluggableTaskBuilder builder = spy(new PluggableTaskBuilder(runIfConfigs, cancelBuilder, pluggableTask, "", ""));
        taskExtension = mock(TaskExtension.class);
        when(taskExtension.execute(eq(TEST_PLUGIN_ID), any())).thenReturn(ExecutionResult.success("yay"));

        builder.build(goPublisher, variableContext, taskExtension, null, null, UTF_8);
        assertThat((TaskExecutionContext) ReflectionUtil.getStaticField(JobConsoleLogger.class, "context")).isNull();
    }