Java Code Examples for hudson.model.Result#ABORTED

The following examples show how to use hudson.model.Result#ABORTED . 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: TelegramBotPublisher.java    From telegram-notifications-plugin with MIT License 6 votes vote down vote up
@Override
public void perform(
        @Nonnull Run<?, ?> run,
        @Nonnull FilePath filePath,
        @Nonnull Launcher launcher,
        @Nonnull TaskListener taskListener) throws InterruptedException, IOException {

    Result result = run.getResult();

    boolean success  = result == Result.SUCCESS  && whenSuccess;
    boolean unstable = result == Result.UNSTABLE && whenUnstable;
    boolean failed   = result == Result.FAILURE  && whenFailed;
    boolean aborted  = result == Result.ABORTED  && whenAborted;

    boolean neededToSend = success || unstable || failed || aborted;

    if (neededToSend) {
        TelegramBotRunner.getInstance().getBot()
                .sendMessage(getMessage(), run, filePath, taskListener);
    }
}
 
Example 2
Source File: CommentBuilder.java    From phabricator-jenkins-plugin with MIT License 6 votes vote down vote up
void processBuildResult(
        Result result,
        boolean commentOnSuccess,
        boolean commentWithConsoleLinkOnFailure,
        boolean runHarbormaster) {
    if (result == Result.SUCCESS) {
        if (comment.length() == 0 && (commentOnSuccess || !runHarbormaster)) {
            comment.append("Build is green");
        }
    } else if (result == Result.UNSTABLE) {
        comment.append("Build is unstable");
    } else if (result == Result.FAILURE) {
        if (!runHarbormaster || commentWithConsoleLinkOnFailure) {
            comment.append("Build has FAILED");
        }
    } else if (result == Result.ABORTED) {
        comment.append("Build was aborted");
    } else {
        logger.info(UBERALLS_TAG, "Unknown build status " + result.toString());
    }
}
 
Example 3
Source File: DecisionMakerTest.java    From office-365-connector-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void DecisionMaker_OnPreviousBuild_StoresParameters() {

    // given
    Run run = mock(Run.class);
    Run previousRun = mock(Run.class);
    Result previousResult = Result.ABORTED;
    when(run.getPreviousBuild()).thenReturn(previousRun);
    when(previousRun.getResult()).thenReturn(previousResult);
    TaskListener taskListener = AbstractTest.mockListener();

    // when
    DecisionMaker decisionMaker = new DecisionMaker(run, taskListener);

    // then
    assertThat((Run) Deencapsulation.getField(decisionMaker, "run")).isSameAs(run);
    assertThat((TaskListener) Deencapsulation.getField(decisionMaker, "taskListener")).isSameAs(taskListener);
    assertThat((Result) Deencapsulation.getField(decisionMaker, "previousResult")).isEqualTo(previousResult);
}
 
Example 4
Source File: CardBuilderTest.java    From office-365-connector-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void calculateSummary_OnSuccess_ReturnsSuccess() {

    // given
    Result lastResult = Result.SUCCESS;
    boolean isRepeatedFailure = false;
    Result[] previousResults = {Result.SUCCESS, Result.NOT_BUILT, Result.ABORTED};

    for (Result previousResult : previousResults) {
        // when
        String status = cardBuilder.calculateSummary(lastResult, previousResult, isRepeatedFailure);

        // then
        assertThat(status).isEqualTo("Success");
    }
}
 
Example 5
Source File: CardBuilderTest.java    From office-365-connector-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void calculateStatus_OnSuccess_ReturnsSuccess() {

    // given
    Result lastResult = Result.SUCCESS;
    boolean isRepeatedFailure = false;
    Result[] previousResults = {Result.SUCCESS, Result.NOT_BUILT, Result.ABORTED};

    for (Result previousResult : previousResults) {
        // when
        String status = cardBuilder.calculateStatus(lastResult, previousResult, isRepeatedFailure);

        // then
        assertThat(status).isEqualTo("Build Success");
    }
}
 
Example 6
Source File: CardBuilder.java    From office-365-connector-plugin with Apache License 2.0 6 votes vote down vote up
String calculateSummary(Result completedResult, Result previousResult, boolean isRepeatedFailure) {

        if (completedResult == Result.SUCCESS) {
            // back to normal
            if (previousResult == Result.FAILURE || previousResult == Result.UNSTABLE) {
                return "Back to Normal";
            }
            // success remains
            return "Success";
        }
        if (completedResult == Result.FAILURE) {
            if (isRepeatedFailure) {
                return "Repeated Failure";
            }
            return "Failed";
        }
        if (completedResult == Result.ABORTED) {
            return "Aborted";
        }
        if (completedResult == Result.UNSTABLE) {
            return "Unstable";
        }

        return completedResult.toString();
    }
 
Example 7
Source File: CardBuilder.java    From office-365-connector-plugin with Apache License 2.0 6 votes vote down vote up
String calculateStatus(Result lastResult, Result previousResult, boolean isRepeatedFailure) {
    if (lastResult == Result.SUCCESS) {
        // back to normal
        if (previousResult == Result.FAILURE || previousResult == Result.UNSTABLE) {
            return "Back to Normal";
        }
        // success remains
        return "Build Success";
    }
    if (lastResult == Result.FAILURE) {
        if (isRepeatedFailure) {
            return "Repeated Failure";
        }
        return "Build Failed";
    }
    if (lastResult == Result.ABORTED) {
        return "Build Aborted";
    }
    if (lastResult == Result.UNSTABLE) {
        return "Build Unstable";
    }

    return lastResult.toString();
}
 
Example 8
Source File: GitLabMessagePublisher.java    From gitlab-plugin with GNU General Public License v2.0 6 votes vote down vote up
private String getNote(Run<?, ?> build, TaskListener listener) {
    String message;
    if (this.replaceSuccessNote && build.getResult() == Result.SUCCESS) {
        message = replaceMacros(build, listener, this.getSuccessNoteText());
    } else if (this.replaceAbortNote && build.getResult() == Result.ABORTED) {
        message = replaceMacros(build, listener, this.getAbortNoteText());
    } else if (this.replaceUnstableNote && build.getResult() == Result.UNSTABLE) {
        message = replaceMacros(build, listener, this.getUnstableNoteText());
    } else if (this.replaceFailureNote && build.getResult() == Result.FAILURE) {
        message = replaceMacros(build, listener, this.getFailureNoteText());
    } else {
        String icon = getResultIcon(build.getResult());
        String buildUrl = Jenkins.getInstance().getRootUrl() + build.getUrl();
        message = MessageFormat.format("{0} Jenkins Build {1}\n\nResults available at: [Jenkins [{2} #{3}]]({4})",
                                       icon, build.getResult().toString(), build.getParent().getDisplayName(), build.getNumber(), buildUrl);
    }
    return message;
}
 
Example 9
Source File: DecisionMaker.java    From office-365-connector-plugin with Apache License 2.0 5 votes vote down vote up
private Run findLastCompletedBuild() {
    Run previousBuild = run.getPreviousBuild();
    while (previousBuild != null && previousBuild.getResult() == Result.ABORTED) {
        previousBuild = previousBuild.getPreviousCompletedBuild();
    }
    return previousBuild;
}
 
Example 10
Source File: CardBuilderTest.java    From office-365-connector-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void calculateStatus_OnAborted_ReturnsAborted() {

    // given
    Result lastResult = Result.ABORTED;
    boolean isRepeatedFailure = true;
    Result previousResult = null;

    // when
    String status = cardBuilder.calculateStatus(lastResult, previousResult, isRepeatedFailure);

    // then
    assertThat(status).isEqualTo("Build Aborted");
}
 
Example 11
Source File: CardBuilderTest.java    From office-365-connector-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void calculateSummary_OnAborted_ReturnsAborted() {

    // given
    Result lastResult = Result.ABORTED;
    boolean isRepeatedFailure = true;
    Result previousResult = null;

    // when
    String status = cardBuilder.calculateSummary(lastResult, previousResult, isRepeatedFailure);

    // then
    assertThat(status).isEqualTo("Aborted");
}
 
Example 12
Source File: CardBuilderTest.java    From office-365-connector-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void getCardThemeColor_OnAbortedResult_ReturnsBallColor() {
    // given
    Result abortedResult = Result.ABORTED;
    String ballColorString = Result.ABORTED.color.getHtmlBaseColor();

    // when
    String themeColor = Deencapsulation.invoke(CardBuilder.class, "getCardThemeColor", abortedResult);
    
    // then
    assertThat(themeColor).isEqualToIgnoringCase(ballColorString);
}
 
Example 13
Source File: NodeRunStatus.java    From blueocean-plugin with MIT License 5 votes vote down vote up
public NodeRunStatus(@Nonnull FlowNode endNode) {
    Result result = null;
    ErrorAction errorAction = endNode.getError();
    WarningAction warningAction = endNode.getPersistentAction(WarningAction.class);
    if (errorAction != null) {
        if(errorAction.getError() instanceof FlowInterruptedException) {
            result = ((FlowInterruptedException) errorAction.getError()).getResult();
        }
        if(result == null || result != Result.ABORTED) {
            this.result = BlueRun.BlueRunResult.FAILURE;
        } else {
            this.result = BlueRun.BlueRunResult.ABORTED;
        }
        this.state = endNode.isActive() ? BlueRun.BlueRunState.RUNNING : BlueRun.BlueRunState.FINISHED;
    } else if (warningAction != null) {
        this.result = new NodeRunStatus(GenericStatus.fromResult(warningAction.getResult())).result;
        this.state = endNode.isActive() ? BlueRun.BlueRunState.RUNNING : BlueRun.BlueRunState.FINISHED;
    } else if (QueueItemAction.getNodeState(endNode) == QueueItemAction.QueueState.QUEUED) {
        this.result = BlueRun.BlueRunResult.UNKNOWN;
        this.state = BlueRun.BlueRunState.QUEUED;
    } else if (QueueItemAction.getNodeState(endNode) == QueueItemAction.QueueState.CANCELLED) {
        this.result = BlueRun.BlueRunResult.ABORTED;
        this.state = BlueRun.BlueRunState.FINISHED;
    } else if (endNode.isActive()) {
        this.result = BlueRun.BlueRunResult.UNKNOWN;
        this.state = BlueRun.BlueRunState.RUNNING;
    } else if (NotExecutedNodeAction.isExecuted(endNode)) {
        this.result = BlueRun.BlueRunResult.SUCCESS;
        this.state = BlueRun.BlueRunState.FINISHED;
    } else {
        this.result = BlueRun.BlueRunResult.NOT_BUILT;
        this.state = BlueRun.BlueRunState.QUEUED;
    }
}
 
Example 14
Source File: SubBuildScheduler.java    From DotCi with MIT License 5 votes vote down vote up
public CurrentBuildState waitForCompletion(final DynamicSubProject c, final TaskListener listener) throws InterruptedException {

        // wait for the completion
        int appearsCancelledCount = 0;
        while (true) {
            Thread.sleep(1000);
            final CurrentBuildState b = c.getCurrentStateByNumber(this.dynamicBuild.getNumber());
            if (b != null) { // its building or is done
                if (b.isBuilding()) {
                    continue;
                } else {
                    final Result buildResult = b.getResult();
                    if (buildResult != null) {
                        return b;
                    }
                }
            } else { // not building or done, check queue
                final Queue.Item qi = c.getQueueItem();
                if (qi == null) {
                    appearsCancelledCount++;
                    listener.getLogger().println(c.getName() + " appears cancelled: " + appearsCancelledCount);
                } else {
                    appearsCancelledCount = 0;
                }

                if (appearsCancelledCount >= 5) {
                    listener.getLogger().println(Messages.MatrixBuild_AppearsCancelled(ModelHyperlinkNote.encodeTo(c)));
                    return new CurrentBuildState("COMPLETED", Result.ABORTED);
                }
            }

        }
    }
 
Example 15
Source File: BuildStatusAction.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
private BuildStatus getStatus(Run<?, ?> build) {
    if (build == null) {
        return BuildStatus.NOT_FOUND;
    } else if (build.isBuilding()) {
        return BuildStatus.RUNNING;
    } else if (build.getResult() == Result.ABORTED) {
        return BuildStatus.CANCELED;
    } else if (build.getResult() == Result.SUCCESS) {
        return BuildStatus.SUCCESS;
    } else if (build.getResult() == Result.UNSTABLE) {
        return BuildStatus.UNSTABLE;
    } else {
        return BuildStatus.FAILED;
    }
}
 
Example 16
Source File: GitLabCommitStatusPublisher.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    Result buildResult = build.getResult();
    if (buildResult == Result.SUCCESS || (buildResult == Result.UNSTABLE && markUnstableAsSuccess)) {
        CommitStatusUpdater.updateCommitStatus(build, listener, BuildState.success, name);
    } else if (buildResult == Result.ABORTED) {
        CommitStatusUpdater.updateCommitStatus(build, listener, BuildState.canceled, name);
    } else {
        CommitStatusUpdater.updateCommitStatus(build, listener, BuildState.failed, name);
    }
    return true;
}
 
Example 17
Source File: GitLabMessagePublisher.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
private String getResultIcon(Result result) {
    if (result == Result.SUCCESS) {
        return ":white_check_mark:";
    } else if (result == Result.ABORTED) {
        return ":point_up:";
    } else if (result == Result.UNSTABLE) {
        return ":warning:";
    } else {
        return ":negative_squared_cross_mark:";
    }
}
 
Example 18
Source File: SubBuildScheduler.java    From DotCi with MIT License 4 votes vote down vote up
private Result getResult(final CurrentBuildState run) {
    return run != null ? run.getResult() : Result.ABORTED;
}
 
Example 19
Source File: DecisionMaker.java    From office-365-connector-plugin with Apache License 2.0 4 votes vote down vote up
private boolean isNotifyAborted(Result result, Webhook webhook) {
    return webhook.isNotifyAborted()
            && result == Result.ABORTED;
}
 
Example 20
Source File: AbstractRunImpl.java    From blueocean-plugin with MIT License 4 votes vote down vote up
private boolean isCompletedOrAborted(){
    Result result = run.getResult();
    return result != null && (result == Result.ABORTED || result.isCompleteBuild());
}