Java Code Examples for hudson.model.Result#SUCCESS
The following examples show how to use
hudson.model.Result#SUCCESS .
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 |
@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: PipelineNodeContainerImpl.java From blueocean-plugin with MIT License | 6 votes |
public PipelineNodeContainerImpl(WorkflowRun run, Link parentLink) { this.run = run; this.self = parentLink.rel("nodes"); WorkflowJob job = run.getParent(); NodeGraphBuilder graphBuilder = NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(run); //If build either failed or is in progress then return union with last successful pipeline run if (run.getResult() != Result.SUCCESS && job.getLastSuccessfulBuild() != null && Integer.parseInt(job.getLastSuccessfulBuild().getId()) < Integer.parseInt(run.getId())) { NodeGraphBuilder pastBuildGraph = NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(job.getLastSuccessfulBuild()); this.nodes = graphBuilder.union(pastBuildGraph.getPipelineNodes(), getLink()); } else { this.nodes = graphBuilder.getPipelineNodes(getLink()); } for (BluePipelineNode node : nodes) { nodeMap.put(node.getId(), node); } }
Example 3
Source File: CardBuilder.java From office-365-connector-plugin with Apache License 2.0 | 6 votes |
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 4
Source File: CardBuilderTest.java From office-365-connector-plugin with Apache License 2.0 | 6 votes |
@Test public void calculateSummary_OnSuccess_ReturnsBackToNormal() { // given Result lastResult = Result.SUCCESS; boolean isRepeatedFailure = false; Result[] previousResults = {Result.FAILURE, Result.UNSTABLE}; for (Result previousResult : previousResults) { // when String status = cardBuilder.calculateSummary(lastResult, previousResult, isRepeatedFailure); // then assertThat(status).isEqualTo("Back to Normal"); } }
Example 5
Source File: GitLabVotePublisher.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
private boolean isSuccessful(Result result) { if (result == Result.SUCCESS) { return true; } else { return false; } }
Example 6
Source File: DockerComposeBuild.java From DotCi with MIT License | 5 votes |
private Result runPlugins(final DynamicBuild dynamicBuild, final List<DotCiPluginAdapter> plugins, final BuildListener listener, final Launcher launcher) { boolean result = true; for (final DotCiPluginAdapter plugin : plugins) { result = result & plugin.perform(dynamicBuild, launcher, listener); } return result ? Result.SUCCESS : Result.FAILURE; }
Example 7
Source File: DecisionMaker.java From office-365-connector-plugin with Apache License 2.0 | 5 votes |
private boolean isNotifyBackToNormal(Result result, Webhook webhook) { if (!webhook.isNotifyBackToNormal() || result != Result.SUCCESS) { return false; } Run previousBuild = findLastCompletedBuild(); if (previousBuild == null) { return false; } else { Result previousResult = previousBuild.getResult(); return (previousResult == Result.FAILURE || previousResult == Result.UNSTABLE); } }
Example 8
Source File: ViewTracker.java From rocket-chat-notifier with Apache License 2.0 | 5 votes |
private Result getResult(View view) { Result ret = Result.SUCCESS; for (TopLevelItem item : view.getAllItems()) { for (Job<?,?> job : item.getAllJobs()) { Run<?, ?> build = job.getLastCompletedBuild(); if(build != null) { Result result = build.getResult(); if(result.isBetterOrEqualTo(Result.FAILURE)) ret = ret.combine(result); } } } return ret; }
Example 9
Source File: BuildResultProcessor.java From phabricator-jenkins-plugin with MIT License | 5 votes |
public Result getBuildResult() { // In Pipeline jobs, as long as no failure happens, the build status stays null. // The PhabricatorNotifier needs to interpret null as "not failed (yet)". if (this.build.getResult() == null) { return Result.SUCCESS; } else { return this.build.getResult(); } }
Example 10
Source File: SubBuildScheduler.java From DotCi with MIT License | 5 votes |
public Result runSubBuilds(final Iterable<Combination> subBuildCombinations, final BuildListener listener) throws InterruptedException, IOException { final Iterable<DynamicSubProject> subProjects = getRunSubProjects(subBuildCombinations); scheduleSubBuilds(subBuildCombinations, this.subBuildFinishListener, listener); Result r = Result.SUCCESS; for (final DynamicSubProject c : subProjects) { final CurrentBuildState runState = waitForCompletion(c, listener); final Result runResult = getResult(runState); r = r.combine(runResult); listener.getLogger().println("Run " + c.getName() + " finished with : " + runResult); // subBuildFinishListener.runFinished(c.getBuildByNumber(dynamicBuild.getNumber()) ); } return r; }
Example 11
Source File: GitLabCommitStatusPublisher.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
@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 12
Source File: GitLabAcceptMergeRequestPublisher.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
@Override protected void perform(Run<?, ?> build, TaskListener listener, GitLabClient client, MergeRequest mergeRequest) { try { if (build.getResult() == Result.SUCCESS) { client.acceptMergeRequest(mergeRequest, "Merge Request accepted by jenkins build success", false); } } catch (WebApplicationException | ProcessingException e) { listener.getLogger().printf("Failed to accept merge request for project '%s': %s%n", mergeRequest.getProjectId(), e.getMessage()); LOGGER.log(Level.SEVERE, String.format("Failed to accept merge request for project '%s'", mergeRequest.getProjectId()), e); } }
Example 13
Source File: BuildStatusAction.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
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 14
Source File: GitLabMessagePublisher.java From gitlab-plugin with GNU General Public License v2.0 | 5 votes |
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 15
Source File: PhabricatorNotifier.java From phabricator-jenkins-plugin with MIT License | 4 votes |
/** * Get the coverage provider for the build * * @param build The current build * @param listener The build listener * @return The current coverage, if any */ private CoverageProvider getCoverageProvider( Run<?, ?> build, FilePath workspace, TaskListener listener, Set<String> includeFiles) { Result buildResult; if (build.getResult() == null) { buildResult = Result.SUCCESS; } else { buildResult = build.getResult(); } if (!buildResult.isBetterOrEqualTo(Result.UNSTABLE)) { return null; } copyCoverageToJenkinsMaster(build, workspace, listener); CoverageProvider coverageProvider = null; Logger logger = new Logger(listener.getLogger()); // First check if any coverage plugins are applied. These take precedence over other providers // Only one coverage plugin provider is supported per build if (Jenkins.getInstance().getPlugin("cobertura") != null) { CoberturaBuildAction coberturaBuildAction = build.getAction(CoberturaBuildAction.class); if (coberturaBuildAction != null) { // Choose only a single coverage provider logger.info(UBERALLS_TAG, "Using coverage metrics from Cobertura Jenkins Plugin"); coverageProvider = new CoberturaPluginCoverageProvider(getCoverageReports(build), includeFiles, coberturaBuildAction); } } if (coverageProvider == null && Jenkins.getInstance().getPlugin("jacoco") != null) { JacocoBuildAction jacocoBuildAction = build.getAction(JacocoBuildAction.class); if (jacocoBuildAction != null) { logger.info(UBERALLS_TAG, "Using coverage metrics from Jacoco Jenkins Plugin"); coverageProvider = new JacocoPluginCoverageProvider(getCoverageReports(build), includeFiles, jacocoBuildAction); } } if (coverageProvider == null) { logger.info(UBERALLS_TAG, "Trying to obtain coverage metrics by parsing coverage xml files"); coverageProvider = new XmlCoverageProvider(getCoverageReports(build), includeFiles); } coverageProvider.computeCoverageIfNeeded(); cleanupCoverageFilesOnJenkinsMaster(build); if (coverageProvider.hasCoverage()) { return coverageProvider; } else { logger.info(UBERALLS_TAG, "No coverage results found"); return null; } }
Example 16
Source File: GitHubCommentPublisherDslContext.java From github-integration-plugin with MIT License | 4 votes |
public void onlySuccessfulBuilds() { verifier = new StatusVerifier(Result.SUCCESS); }
Example 17
Source File: CardBuilder.java From office-365-connector-plugin with Apache License 2.0 | 4 votes |
private Result getCompletedResult(Run run) { return run.getResult() == null ? Result.SUCCESS : run.getResult(); }
Example 18
Source File: DashboardView.java From jenkins-deployment-dashboard-plugin with MIT License | 4 votes |
@JavaScriptMethod public String deploy(String version, String environment) { LOGGER.info("Deploy version " + version + " to environment " + environment); // Get the environment with corresponding build-job Environment buildEnvironment = null; for (Environment env : environments) { if (env.getAwsInstance().equals(environment)) { buildEnvironment = env; break; } } final AbstractProject buildJob = Jenkins.getInstance().getItemByFullName(buildEnvironment.getBuildJob(), AbstractProject.class); LOGGER.info("Executing job: " + buildJob); if (buildJob == null) { return String.format(Messages.DashboardView_buildJobNotFound(), buildEnvironment.getName()); } if ((!buildJob.isBuildable()) || (!buildJob.isParameterized())) { return Messages.DashboardView_deploymentCannotBeExecuted(); } final ParametersAction versionParam = new ParametersAction(new StringParameterValue(PARAM_VERSION, version)); final ParametersAction environmentParam = new ParametersAction(new StringParameterValue(PARAM_ENVIRONMENT, environment)); final ParametersAction ec2RegionParam = new ParametersAction(new StringParameterValue(PARAM_EC2_REGION, environment)); final ParametersAction awsKeyParam = new ParametersAction(new StringParameterValue(PARAM_AWS_KEY, environment)); List<ParametersAction> actions = Arrays.asList(versionParam, environmentParam, ec2RegionParam, awsKeyParam); QueueTaskFuture<AbstractBuild> scheduledBuild = buildJob.scheduleBuild2(2, new Cause.UserIdCause(), actions); Result result = Result.FAILURE; try { AbstractBuild finishedBuild = scheduledBuild.get(); result = finishedBuild.getResult(); LOGGER.info("Build finished with result: " + result + " completed in: " + finishedBuild.getDurationString() + ". "); } catch (Exception e) { LOGGER.severe("Error while waiting for build " + scheduledBuild.toString() + "."); LOGGER.severe(e.getMessage()); LOGGER.severe(ExceptionUtils.getFullStackTrace(e)); return String.format(Messages.DashboardView_buildJobFailed(), buildJob.getName()); } if (result == Result.SUCCESS) { return String.format(Messages.DashboardView_buildJobScheduledSuccessfully(), buildJob.getName()); } return String.format(Messages.DashboardView_buildJobSchedulingFailed(), buildJob.getName()); }
Example 19
Source File: DecisionMaker.java From office-365-connector-plugin with Apache License 2.0 | 4 votes |
private boolean isNotifySuccess(Result result, Webhook webhook) { return webhook.isNotifySuccess() && result == Result.SUCCESS; }
Example 20
Source File: ZulipNotifier.java From zulip-plugin with MIT License | 2 votes |
/** * Helper method to get build result from {@link Run}<br/> * <i>Since scripted pipeline have no post build concept, the Result variable of successful builds will<br/> * not be set yet. In that case we simply assume the build is a success</i> * * @param build The run to get build result from * @return The build result */ private static Result getBuildResult(Run<?, ?> build) { return build.getResult() != null ? build.getResult() : Result.SUCCESS; }