Java Code Examples for hudson.model.Run#getUrl()
The following examples show how to use
hudson.model.Run#getUrl() .
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 |
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 2
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 3
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 4
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 5
Source File: GitLabMessagePublisher.java From gitlab-plugin with GNU General Public License v2.0 | 6 votes |
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 6
Source File: BuildOverInfo.java From qy-wechat-notification-plugin with Apache License 2.0 | 5 votes |
public BuildOverInfo(String projectName, Run<?, ?> run, NotificationConfig config){ //使用时间 this.useTimeString = run.getTimestampString(); //控制台地址 StringBuilder urlBuilder = new StringBuilder(); String jenkinsUrl = NotificationUtil.getJenkinsUrl(); if(StringUtils.isNotEmpty(jenkinsUrl)){ String buildUrl = run.getUrl(); urlBuilder.append(jenkinsUrl); if(!jenkinsUrl.endsWith("/")){ urlBuilder.append("/"); } urlBuilder.append(buildUrl); if(!buildUrl.endsWith("/")){ urlBuilder.append("/"); } urlBuilder.append("console"); } this.consoleUrl = urlBuilder.toString(); //工程名称 this.projectName = projectName; //环境名称 if(config.topicName!=null){ topicName = config.topicName; } //结果 result = run.getResult(); }
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)); }
Example 9
Source File: GitHubPRStatusBuilder.java From github-integration-plugin with MIT License | 5 votes |
@Override public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException { // No triggers in Run class, but we need it final GitHubPRTrigger trigger = ghPRTriggerFromRun(run); if (isNull(trigger)) { // silently skip. TODO implement error handler, like in publishers return; } GitHubPRCause cause = ghPRCauseFromRun(run); if (isNull(cause)) { return; } // GitHub status for commit try { if (nonNull(statusMessage)) { String url = trigger.getDescriptor().getJenkinsURL() + run.getUrl(); trigger.getRemoteRepository().createCommitStatus( cause.getHeadSha(), GHCommitState.PENDING, url, statusMessage.expandAll(run, listener), run.getParent().getFullName() ); } } catch (Exception e) { listener.getLogger().println("Can't update build description"); LOGGER.error("Can't set commit status", e); } }
Example 10
Source File: History.java From junit-plugin with MIT License | 5 votes |
private void generateUrl() { Run<?,?> build = o.getRun(); String buildLink = build.getUrl(); String actionUrl = o.getTestResultAction().getUrlName(); final String rootUrl = Helper.getActiveInstance().getRootUrl(); if (rootUrl == null) { throw new IllegalStateException("Jenkins root URL not available"); } this.url = rootUrl + buildLink + actionUrl + o.getUrl(); }
Example 11
Source File: DingTalkPipeline.java From dingtalk-plugin with MIT License | 4 votes |
@Override public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException { EnvVars envVars = run.getEnvironment(listener); boolean defaultBtns = MsgTypeEnum.ACTION_CARD.equals(type) && StringUtils.isEmpty(singleTitle) && (btns == null || btns.isEmpty()); if (defaultBtns) { String jobUrl = rootPath + run.getUrl(); this.btns = Utils.createDefaultBtns(jobUrl); } else if (btns != null) { btns.forEach(item -> { item.setTitle( envVars.expand( item.getTitle() ) ); item.setActionUrl( envVars.expand( item.getActionUrl() ) ); }); } if (at != null) { String atStr = envVars.expand( Utils.join(at) ); this.at = new HashSet<>( Arrays.asList( Utils.split(atStr) ) ); } String result = service.send( robot, MessageModel.builder() .type(type) .atMobiles(at) .atAll(atAll) .title( envVars.expand(title) ) .text( envVars.expand( Utils.join(text) ) ) .messageUrl( envVars.expand(messageUrl) ) .picUrl( envVars.expand(picUrl) ) .singleTitle( envVars.expand(singleTitle) ) .singleUrl( envVars.expand(singleUrl) ) .btns(btns) .btnOrientation( getBtnLayout() ) .hideAvatar(isHideAvatar()) .build() ); if (!StringUtils.isEmpty(result)) { Logger.error(listener, result); } }
Example 12
Source File: GitHubPRBuildStatusPublisher.java From github-integration-plugin with MIT License | 4 votes |
@Override public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException { PrintStream listenerLogger = listener.getLogger(); String publishedURL = getTriggerDescriptor().getJenkinsURL(); if (getStatusVerifier() != null && !getStatusVerifier().isRunAllowed(run)) { return; } if (isEmpty(publishedURL)) { return; } GHCommitState state = getCommitState(run, unstableAs); GitHubPRCause c = ghPRCauseFromRun(run); String statusMsgValue = getStatusMsg().expandAll(run, listener); String buildUrl = publishedURL + run.getUrl(); LOGGER.info("Setting status of {} to {} with url {} and message: {}", c.getHeadSha(), state, buildUrl, statusMsgValue); // TODO check permissions to write human friendly message final GitHubPRTrigger trigger = ghPRTriggerFromRun(run); if (isNull(trigger)) { listener.error("Can't get trigger for this run! Silently skipping. " + "TODO implement error handler, like in publishers"); return; } try { trigger.getRemoteRepository().createCommitStatus(c.getHeadSha(), state, buildUrl, statusMsgValue, run.getParent().getFullName()); } catch (IOException ex) { if (nonNull(buildMessage)) { String comment = null; LOGGER.error("Could not update commit status of the Pull Request on GitHub. ", ex); if (state == GHCommitState.SUCCESS) { comment = buildMessage.getSuccessMsg().expandAll(run, listener); } else if (state == GHCommitState.FAILURE) { comment = buildMessage.getFailureMsg().expandAll(run, listener); } listenerLogger.println("Adding comment..."); LOGGER.info("Adding comment, because: ", ex); addComment(c.getNumber(), comment, run, listener); } else { listenerLogger.println("Could not update commit status of the Pull Request on GitHub." + ex.getMessage()); LOGGER.error("Could not update commit status of the Pull Request on GitHub.", ex); } handlePublisherError(run); } }
Example 13
Source File: BuildInfo.java From DotCi with MIT License | 4 votes |
public BuildInfo(Run run) { this.timestamp = run.getTimestamp(); this.url = "/" + run.getUrl(); this.name = run.getFullDisplayName(); this.result = run.isBuilding() ? "Building" : run.getResult().toString(); }