UpdateGitLabCommitStatusStepExecution(StepContext context, UpdateGitLabCommitStatusStep step) throws Exception { super(context); this.step = step; run = context.get(Run.class); }
@Override public boolean start() throws Exception { body = getContext().newBodyInvoker() .withCallback(new BodyExecutionCallback() { @Override public void onStart(StepContext context) { .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 }
/** * Makes sure that the given {@link StepContext} has all the context parameters this descriptor wants to see, * and if not, throw {@link MissingContextVariableException} indicating which variable is missing. */ public final void checkContextAvailability(StepContext c) throws MissingContextVariableException, IOException, InterruptedException { // TODO the order here is nondeterministic; should we pick the lexicographic first? Or extend MissingContextVariableException to take a Set<Class<?>> types? for (Class<?> type : getRequiredContext()) { Object v = c.get(type); if (v==null) throw new MissingContextVariableException(type); } }
@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); } })
@Override public void onSuccess(StepContext context, Object result) { CommitStatusUpdater.updateCommitStatus(run, getTaskListener(context), BuildState.success, name, step.builds, step.connection); context.onSuccess(result); }
/** * Convenience method around {@link #cancel(CauseOfInterruption...)} in case * the cause is a random exception. */ public boolean cancel(Throwable t) { return cancel(new ExceptionCause(t)); }
@Override public void stop(@Nonnull Throwable cause) throws Exception { // should be no need to do anything special (but verify in JENKINS-26148) if (body != null) { String name = StringUtils.isEmpty(step.name) ? "jenkins" : step.name; CommitStatusUpdater.updateCommitStatus(run, null, BuildState.canceled, name, step.builds, step.connection); body.cancel(cause); } }
@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; }
AddGitLabMergeRequestCommentStepExecution(StepContext context, AddGitLabMergeRequestCommentStep step) throws Exception { super(context); this.step = step; run = context.get(Run.class); }
@Override public void onFailure(StepContext context, Throwable t) { PendingBuildsAction action = run.getAction(PendingBuildsAction.class); if (action != null) { BuildState state = t instanceof FlowInterruptedException ? BuildState.canceled : BuildState.failed; for (String name : action.getBuilds()) { CommitStatusUpdater.updateCommitStatus(run, getTaskListener(context), state, name); } } context.onFailure(t); } })
@Override public void onSuccess(StepContext context, Object result) { PendingBuildsAction action = run.getAction(PendingBuildsAction.class); if (action != null && !action.getBuilds().isEmpty()) { TaskListener taskListener = getTaskListener(context); if (taskListener != null) { taskListener.getLogger().println("There are still pending GitLab builds. Please check your configuration"); } } context.onSuccess(result); }
@Override public void stop(@Nonnull Throwable cause) throws Exception { // should be no need to do anything special (but verify in JENKINS-26148) if (body != null) { PendingBuildsAction action = run.getAction(PendingBuildsAction.class); if (action != null) { for (String name : action.getBuilds()) { CommitStatusUpdater.updateCommitStatus(run, null, BuildState.canceled, name); } } body.cancel(cause); } }
GitLabBuildStepExecution(StepContext context, GitLabBuildsStep step) throws Exception { super(context); this.step = step; run = context.get(Run.class); }
AcceptGitLabMergeRequestStepExecution(StepContext context, AcceptGitLabMergeRequestStep step) throws Exception { super(context); this.step = step; run = context.get(Run.class); }
GitLabCommitStatusStepExecution(StepContext context, GitLabCommitStatusStep step) throws Exception { super(context); this.step = step; run = context.get(Run.class); }