Source:
<code>protected Callable<Boolean> createTaskFor(final CommandLine commandLine, final BuildLogger logger, final long timeout, final BuilderConfiguration configuration) { return new Callable<Boolean>() { @Override public Boolean call() throws Exception { BaseBuilderRequest request = configuration.getRequest(); getSourcesManager() .getSources(logger, request.getWorkspace(), request.getProject(), request.getSourcesUrl(), configuration.getWorkDir()); eventService.publish(BuilderEvent.buildTimeStartedEvent(request.getId(), request.getWorkspace(), request.getProject(), System.currentTimeMillis())); eventService.publish(BuilderEvent.beginEvent(request.getId(), request.getWorkspace(), request.getProject())); StreamPump output = null; Watchdog watcher = null; int result = -1; try { ProcessBuilder processBuilder = new ProcessBuilder().command(commandLine.toShellCommand()).directory( configuration.getWorkDir()).redirectErrorStream(true); modifyCommandEnvironment(processBuilder.environment(), configuration); <START> Process process = processBuilder.start(); <END> if (timeout > 0) { watcher = new Watchdog(getName().toUpperCase() + "-WATCHDOG", timeout, TimeUnit.SECONDS); watcher.start(new CancellableProcessWrapper(process, new Cancellable.Callback() { @Override public void cancelled(Cancellable cancellable) { try { logger.writeLine("[ERROR] Your build has been shutdown due to timeout."); } catch (IOException e) { LOG.error(e.getMessage(), e); } } })); } output = new StreamPump(); output.start(process, logger); try { result = process.waitFor(); } catch (InterruptedException e) { Thread.interrupted(); ProcessUtil.kill(process); } try { output.await(); } catch (InterruptedException e) { Thread.interrupted(); } } finally { if (watcher != null) { watcher.stop(); } if (output != null) { output.stop(); } } LOG.debug("Done: {}, exit code: {}", commandLine, result); return result == 0; } }; }</code><technical_language>processBuilder.start() - need wrapped some timer , actual time spent in command execution. - in another future change</technical_language>

Target:
protected Callable<Boolean> createTaskFor(final CommandLine commandLine, final BuildLogger logger, final long timeout, final BuilderConfiguration configuration) { return new Callable<Boolean>() { @Override public Boolean call() throws Exception { BaseBuilderRequest request = configuration.getRequest(); if (!prepareWorkingDirectory(configuration, logger)) { return Boolean.FALSE; } eventService.publish(BuilderEvent.buildTimeStartedEvent(request.getId(), request.getWorkspace(), request.getProject(), System.currentTimeMillis())); eventService.publish(BuilderEvent.beginEvent(request.getId(), request.getWorkspace(), request.getProject())); int result = -1; boolean terminated = false; ProcessBuilder processBuilder = createProcessBuilder(commandLine, configuration); try (StreamPump output = new StreamPump()) { Process process = processBuilder.start(); terminated = waitForProcess(process, timeout, configuration, logger); try { output.await(); } catch (InterruptedException e) { Thread.interrupted(); } } if (terminated) { try { logger.writeLine("[ERROR] Your build has been shutdown due to timeout."); } catch (IOException e) { LOG.error(e.getMessage(), e); } } LOG.debug("Done: {}, exit code: {}", commandLine, result); return result == 0; } }; }