@Override public boolean start() throws Exception { final String name = StringUtils.isEmpty(step.name) ? "jenkins" : step.name; body = getContext().newBodyInvoker() .withCallback(new BodyExecutionCallback() { @Override public void onStart(StepContext context) { CommitStatusUpdater.updateCommitStatus(run, getTaskListener(context), BuildState.running, name, step.builds, step.connection); PendingBuildsAction action = run.getAction(PendingBuildsAction.class); if (action != null) { action.startBuild(name); } } @Override public void onSuccess(StepContext context, Object result) { CommitStatusUpdater.updateCommitStatus(run, getTaskListener(context), BuildState.success, name, step.builds, step.connection); context.onSuccess(result); } @Override public void onFailure(StepContext context, Throwable t) { BuildState state = t instanceof FlowInterruptedException ? BuildState.canceled : BuildState.failed; CommitStatusUpdater.updateCommitStatus(run, getTaskListener(context), state, name, step.builds, step.connection); context.onFailure(t); } }) .start(); return false; }
@Override public boolean start() throws Exception { body = getContext().newBodyInvoker() .withCallback(new BodyExecutionCallback() { @Override
/** * Checks if this step was called with a body. * @return true if {@link StepDescriptor#takesImplicitBlockArgument} is true, and such a body was in fact passed in; false otherwise */ public boolean hasBody() { // Default implementation, but should be overridden: try { newBodyInvoker(); return true; } catch (IllegalStateException x) { return false; } }
@Override public boolean start() throws Exception { StepContext context = getContext(); context.newBodyInvoker() .withCallback(new Callback()) .start(); return false; }
@Override public void onResume() { recurrencePeriod = MIN_RECURRENCE_PERIOD; if (body == null) { // Restarted while waiting for the timer to go off. Rerun now. body = getContext().newBodyInvoker().withCallback(new Callback(id)).start(); } // otherwise we are in the middle of the body already, so let it run }
@Override public void run() { task = null; body = getContext().newBodyInvoker().withCallback(new Callback(id)).start(); } }, recurrencePeriod, TimeUnit.MILLISECONDS);
@Override public boolean start() throws Exception { StepContext context = getContext(); context.newBodyInvoker() .withCallback(new Callback(count)) .start(); return false; // execution is asynchronous }
@Override public boolean start() throws Exception { getContext().newBodyInvoker() .withCallback(BodyExecutionCallback.wrap(getContext())) .start(); return false; }
@Override public boolean start() throws Exception { FilePath dir = getContext().get(FilePath.class).child(path); getContext().get(TaskListener.class).getLogger().println("Running in " + dir); getContext().newBodyInvoker() .withContext(dir) // Could use a dedicated BodyExecutionCallback here if we wished to print a message at the end ("Returning to ${cwd}"): .withCallback(BodyExecutionCallback.wrap(getContext())) .start(); return false; }
@Override public boolean start() throws Exception { StepContext context = getContext(); sockets = new ArrayList<String>(); initRemoteAgent(); context.newBodyInvoker(). withContext(EnvironmentExpander.merge(getContext().get(EnvironmentExpander.class), new ExpanderImpl(this))). withCallback(new Callback(this)).withDisplayName(null).start(); return false; }
@Override public boolean start() throws Exception { listener.getLogger().println("wrapping in a " + step.curve.getDescription()); getContext().newBodyInvoker().withCallback(BodyExecutionCallback.wrap(getContext())).start(); return false; }
private void doStart() throws Exception { println("starting background part of step"); startEnter.release(); startExit.acquire(); println("starting body"); getContext().newBodyInvoker().withCallback(new Callback()).start(); } private final class Callback extends TailCall {
@Override public final boolean start() throws Exception { KeyMaterialFactory keyMaterialFactory = newKeyMaterialFactory(); KeyMaterial material = keyMaterialFactory.materialize(); getContext().newBodyInvoker(). withContext(EnvironmentExpander.merge(getContext().get(EnvironmentExpander.class), new Expander(material))). withCallback(new Callback(material)). start(); return false; }
@Override public boolean onStart(SessionManager sessionManager) throws Exception { sessionManager.start(); getContext().newBodyInvoker(). withContext(EnvironmentExpander.merge(getContext().get(EnvironmentExpander.class), new NamespaceExpander(session.getNamespace()))). withCallback(new SessionManagerStopCallback(sessionManager)). start(); return false; }
@Override public boolean start() throws Exception { StepContext context = getContext(); if (obj instanceof ConsoleLogFilter) { obj = BodyInvoker.mergeConsoleLogFilters(context.get(ConsoleLogFilter.class), (ConsoleLogFilter) obj); } else if (obj instanceof LauncherDecorator) { obj = BodyInvoker.mergeLauncherDecorators(context.get(LauncherDecorator.class), (LauncherDecorator) obj); } else if (obj instanceof EnvironmentExpander) { obj = EnvironmentExpander.merge(context.get(EnvironmentExpander.class), (EnvironmentExpander) obj); } context.newBodyInvoker().withContext(obj).withCallback(BodyExecutionCallback.wrap(context)).start(); return false; }
@Override public boolean onStart(SessionManager sessionManager) throws Exception { sessionManager.start(); getContext().newBodyInvoker(). withContext(EnvironmentExpander.merge(getContext().get(EnvironmentExpander.class), new NamespaceExpander(session.getNamespace()))). withCallback(new SessionManagerStopCallback(sessionManager)). start(); return false; }
@Override public boolean start() throws Exception { body = getContext().newBodyInvoker().withCallback(BodyExecutionCallback.wrap(getContext())).start(); return false; } @Override public void stop(Throwable cause) throws Exception {
@Override public boolean start() throws Exception { getContext().newBodyInvoker().withCallback(BodyExecutionCallback.wrap(getContext())).start(); return false; } }
@Override public boolean start() throws Exception { FilePath f = getContext().get(FilePath.class).child(file); getContext().newBodyInvoker(). withContext(BodyInvoker.mergeConsoleLogFilters(getContext().get(ConsoleLogFilter.class), new TeeFilter(f))). withCallback(BodyExecutionCallback.wrap(getContext())). start(); return false; }
@Override public boolean start() throws Exception { StepContext context = getContext(); value = "one"; context.newBodyInvoker(). withContexts(EnvironmentExpander.merge(context.get(EnvironmentExpander.class), new ExpanderImpl(this))). withCallback(BodyExecutionCallback.wrap(context)). start(); return false; } @Override public void onResume() {