Java Code Examples for hudson.model.Cause#getShortDescription()
The following examples show how to use
hudson.model.Cause#getShortDescription() .
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: InfluxDbNotifier.java From github-autostatus-plugin with MIT License | 6 votes |
/** * Sends a state change to InfluxDB. * * @param jobName the name of the job * @param stageItem stage item describing the new state */ @Override public void notifyBuildStageStatus(String jobName, BuildStage stageItem) { if (stageItem.getBuildState() == BuildStage.State.Pending) { return; } String buildUrl = stageItem.getRun().getUrl(); int buildNumber = stageItem.getRun().getNumber(); Cause cause = stageItem.getRun().getCause(Cause.class); String buildCause = cause == null ? BuildNotifierConstants.DEFAULT_STRING : cause.getShortDescription(); String data = config.getSchema().formatStage(jobName, repoOwner, repoName, branchName, stageItem.getStageName(), stageItem.getBuildState().toString(), stageItem.getDuration(), stageItem.isPassed() ? 1 : 0, buildUrl, buildNumber, buildCause); postData(data); }
Example 2
Source File: InfluxDbNotifier.java From github-autostatus-plugin with MIT License | 6 votes |
private void notifyCoverage(String jobName, @Nullable CodeCoverage coverageInfo, Run<?, ?> run) { if (coverageInfo != null) { String buildUrl = run.getUrl(); int buildNumber = run.getNumber(); Cause cause = run.getCause(Cause.class); String buildCause = cause == null ? BuildNotifierConstants.DEFAULT_STRING : cause.getShortDescription(); String data = config.getSchema().formatCoverage(jobName, repoOwner, repoName, branchName, coverageInfo.getClasses(), coverageInfo.getConditionals(), coverageInfo.getFiles(), coverageInfo.getLines(), coverageInfo.getMethods(), coverageInfo.getPackages(), coverageInfo.getInstructions(), buildUrl, buildNumber, buildCause); postData(data); } }
Example 3
Source File: InfluxDbNotifier.java From github-autostatus-plugin with MIT License | 6 votes |
private void notifyTestResults(String jobName, @Nullable TestResults testResults, Run<?, ?> run) { if (testResults != null) { String buildUrl = run.getUrl(); int buildNumber = run.getNumber(); Cause cause = run.getCause(Cause.class); String buildCause = cause == null ? BuildNotifierConstants.DEFAULT_STRING : cause.getShortDescription(); String data = config.getSchema().formatTests(jobName, repoOwner, repoName, branchName, testResults.getPassedTestCaseCount(), testResults.getSkippedTestCaseCount(), testResults.getFailedTestCaseCount(), buildUrl, buildNumber, buildCause); postData(data); for (TestSuite testSuite : testResults.getTestSuites()) { notifyTestSuite(jobName, testSuite, run); } } }
Example 4
Source File: InfluxDbNotifier.java From github-autostatus-plugin with MIT License | 6 votes |
private String notifyTestCase(String jobName, String suiteName, TestCase testCase, Run<?, ?> run) { String buildUrl = run.getUrl(); int buildNumber = run.getNumber(); Cause cause = run.getCause(Cause.class); String buildCause = cause == null ? BuildNotifierConstants.DEFAULT_STRING : cause.getShortDescription(); String data = config.getSchema().formatTestCase(jobName, repoOwner, repoName, branchName, suiteName, testCase.getName(), testCase.getPassedCount(), testCase.getSkippedCount(), testCase.getFailedCount(), buildUrl, buildNumber, buildCause); return data; }
Example 5
Source File: HttpNotifier.java From github-autostatus-plugin with MIT License | 6 votes |
private BuildStatus constructBuildStatus(BuildStage.State buildState, Map<String, Object> parameters) { Run<?, ?> run = (Run<?, ?>) parameters.get(BuildNotifierConstants.BUILD_OBJECT); String jobName = (String) parameters.getOrDefault(BuildNotifierConstants.JOB_NAME, BuildNotifierConstants.DEFAULT_STRING); long blockedDuration = BuildNotifierConstants.getLong(parameters, BuildNotifierConstants.BLOCKED_DURATION); String buildUrl = run.getUrl(); int buildNumber = run.getNumber(); long buildDuration = BuildNotifierConstants.getLong(parameters, BuildNotifierConstants.JOB_DURATION) - blockedDuration; Cause cause = run.getCause(Cause.class); String buildCause = cause == null ? BuildNotifierConstants.DEFAULT_STRING : cause.getShortDescription(); BuildStatus result = new org.jenkinsci.plugins.githubautostatus.model.BuildStatus(); result.setRepoOwner(repoOwner); result.setRepoName(repoName); result.setJobName(jobName); result.setBranch(branchName); result.setBuildUrl(buildUrl); result.setBuildNumber(buildNumber); result.setTrigger(buildCause); result.setBlocked(blockedDuration > 0); result.setBlockedTime(blockedDuration); result.setDuration(buildDuration); result.setPassed(buildState == BuildStage.State.CompletedSuccess); result.setResult(buildState); result.setTimestamp(Clock.system(TimeZone.getTimeZone("UTC").toZoneId()).millis() / 1000); return result; }
Example 6
Source File: CauseDTO.java From kubernetes-pipeline-plugin with Apache License 2.0 | 6 votes |
public CauseDTO(Cause cause) { this.shortDescription = cause.getShortDescription(); if (cause instanceof Cause.UserIdCause) { Cause.UserIdCause userIdCause = (Cause.UserIdCause) cause; this.userId = userIdCause.getUserId(); this.userName = userIdCause.getUserName(); } else if (cause instanceof Cause.RemoteCause) { Cause.RemoteCause remoteCause = (Cause.RemoteCause) cause; this.remoteAddr = remoteCause.getAddr(); this.remoteNote = remoteCause.getNote(); } else if (cause instanceof Cause.UpstreamCause) { Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) cause; this.upstreamProject = upstreamCause.getUpstreamProject(); this.upstreamUrl = upstreamCause.getUpstreamUrl(); } }
Example 7
Source File: InfluxDbNotifier.java From github-autostatus-plugin with MIT License | 5 votes |
/** * Sends the final build status to InfluxDB. * * @param buildState the new state * @param parameters build parameters */ @Override public void notifyFinalBuildStatus(BuildStage.State buildState, Map<String, Object> parameters) { Run<?, ?> run = (Run<?, ?>) parameters.get(BuildNotifierConstants.BUILD_OBJECT); String jobName = (String) parameters.getOrDefault(BuildNotifierConstants.JOB_NAME, BuildNotifierConstants.DEFAULT_STRING); int passed = buildState == BuildStage.State.CompletedSuccess ? 1 : 0; long blockedDuration = BuildNotifierConstants.getLong(parameters, BuildNotifierConstants.BLOCKED_DURATION); int blocked = blockedDuration > 0 ? 1 : 0; String buildUrl = run.getUrl(); int buildNumber = run.getNumber(); Cause cause = run.getCause(Cause.class); String buildCause = cause == null ? BuildNotifierConstants.DEFAULT_STRING : cause.getShortDescription(); String data = config.getSchema().formatJob(jobName, repoOwner, repoName, branchName, buildState.toString(), blocked, BuildNotifierConstants.getLong(parameters, BuildNotifierConstants.JOB_DURATION) - blockedDuration, blockedDuration, passed, buildUrl, buildNumber, buildCause); postData(data); if (!this.config.getIgnoreSendingTestResultsToInflux()) { notifyTestResults(jobName, (TestResults) parameters.get(BuildNotifierConstants.TEST_CASE_INFO), run); } if (!this.config.getIgnoreSendingTestCoverageToInflux()) { notifyCoverage(jobName, (CodeCoverage) parameters.get(BuildNotifierConstants.COVERAGE_INFO), run); } }
Example 8
Source File: InfluxDbNotifier.java From github-autostatus-plugin with MIT License | 5 votes |
private void notifyTestSuite(String jobName, TestSuite testSuite, Run<?, ?> run) { String suiteName = testSuite.getName(); String buildUrl = run.getUrl(); int buildNumber = run.getNumber(); Cause cause = run.getCause(Cause.class); String buildCause = cause == null ? BuildNotifierConstants.DEFAULT_STRING : cause.getShortDescription(); List<String> testSuiteQuery = new ArrayList<>(); String data = config.getSchema().formatTestSuite(jobName, repoOwner, repoName, branchName, suiteName, testSuite.getDuration(), testSuite.getPassedTestCaseCount(), testSuite.getSkippedTestCaseCount(), testSuite.getFailedTestCaseCount(), buildUrl, buildNumber, buildCause); testSuiteQuery.add(data); for (TestCase testCase : testSuite.getTestCases()) { testSuiteQuery.add(notifyTestCase(jobName, suiteName, testCase, run)); } postData(String.join("\\n", testSuiteQuery)); }