/** * @see #createCommitStatus(String, GHCommitState,String,String,String) */ public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description) throws IOException { return createCommitStatus(sha1, state, targetUrl, description, null); }
/** * @see #createCommitStatus(String, GHCommitState,String,String,String) */ public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description) throws IOException { return createCommitStatus(sha1, state, targetUrl, description, null); }
/** * @see #createCommitStatus(String, GHCommitState,String,String,String) */ public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description) throws IOException { return createCommitStatus(sha1, state, targetUrl, description,null); }
public FormValidation doTestUpdateStatus( @QueryParameter("serverAPIUrl") final String serverAPIUrl, @QueryParameter("credentialsId") final String credentialsId, @QueryParameter("repo") final String repoName, @QueryParameter("sha1") final String sha1, @QueryParameter("state") final GHCommitState state, @QueryParameter("url") final String url, @QueryParameter("message2") final String message, @QueryParameter("context") final String context) { try { GitHubBuilder builder = getBuilder(null, serverAPIUrl, credentialsId); if (builder == null) { return FormValidation.error("Unable to look up GitHub credentials using ID: " + credentialsId + "!!"); } GitHub gh = builder.build(); GHRepository repo = gh.getRepository(repoName); repo.createCommitStatus(sha1, state, url, message, context); return FormValidation.ok("Updated status of: " + sha1); } catch (Exception ex) { return FormValidation.error("Unable to update status: " + ex); } }
void updateCommitStatus(String revision, String pipelineStage, String trackbackURL, String repository, GHCommitState state, String usernameToUse, String passwordToUse, String oauthAccessTokenToUse, String endPointToUse) throws Exception { GitHub github = createGitHubClient(usernameToUse, passwordToUse, oauthAccessTokenToUse, endPointToUse); GHRepository ghRepository = github.getRepository(repository); ghRepository.createCommitStatus(revision, state, trackbackURL, "", pipelineStage); }
private void setCommitStatus(final BuildCause cause, final DynamicProject project) { final BuildCause buildCause = cause; final String sha = buildCause.getSha(); if (sha != null) { final GHRepository githubRepository = getGithubRepository(project); final String context = buildCause.getPullRequestNumber() != null ? "DotCi/PR" : "DotCi/push"; try { githubRepository.createCommitStatus(sha, GHCommitState.PENDING, getJenkinsRootUrl(), "Build in queue.", context); } catch (final IOException e) { LOGGER.log(Level.WARNING, "Failed to Update commit status", e); } } }
repo.createCommitStatus(sha1, state, url, message, context); } catch (IOException e) { throw new GhprbCommitStatusException(e, state, message, pullId);
@Override public void onInitialize(final DynamicBuild build) { final GHRepository repository = getGithubRepository(build); try { String url = ""; try { url = build.getFullUrl(); } catch (final Exception e) { // do nothing } repository.createCommitStatus(build.getSha(), GHCommitState.PENDING, url, "Build in progress", getContext(build)); } catch (final Exception e) { // Ignore if cannot create a pending status LOGGER.log(Level.WARNING, "Failed to Update commit status", e); // printErrorToBuildConsole(listener, e); } }
@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); } }
@Override public boolean apply(GitHubBranchCause cause) { try { cause.setPollingLogFile(trigger.getPollingLogAction().getPollingLogFile()); StringBuilder sb = new StringBuilder(); sb.append("Jenkins queued the run (").append(cause.getReason()).append(")"); if (trigger.isCancelQueued() && cancelQueuedBuildByBranchName(cause.getBranchName())) { sb.append(". Queued builds aborted"); } QueueTaskFuture<?> queueTaskFuture = startJob(cause); if (isNull(queueTaskFuture)) { LOGGER.error("{} job didn't start", job.getFullName()); } LOGGER.info(sb.toString()); // remote connection if (trigger.isPreStatus()) { trigger.getRemoteRepository() .createCommitStatus(cause.getCommitSha(), GHCommitState.PENDING, null, sb.toString(), job.getFullName()); } } catch (IOException e) { LOGGER.error("Can't trigger build ({})", e.getMessage(), e); return false; } return true; }
ghRepository.createCommitStatus(commitSha, state, url, message, context); } catch (IOException e) { throw new GhprbCommitStatusException(e, state, message, prId);
repository.createCommitStatus(cause.getHeadSha(), config.getState(), buildUrl,
private static void createCommitStatus(@NonNull GHRepository repo, @NonNull String revision, @NonNull GHCommitState state, @NonNull String url, @NonNull String message, @NonNull SCMHead head) throws IOException { LOGGER.log(Level.FINE, "{0}/commit/{1} {2} from {3}", new Object[] {repo.getHtmlUrl(), revision, state, url}); String context; if (head instanceof PullRequestSCMHead) { if (((PullRequestSCMHead) head).isMerge()) { context = "continuous-integration/jenkins/pr-merge"; } else { context = "continuous-integration/jenkins/pr-head"; } } else { context = "continuous-integration/jenkins/branch"; } repo.createCommitStatus(revision, state, url, message, context); }
for (MatrixConfiguration config : configs) { trigger.getRemoteRepository() .createCommitStatus(cause.getHeadSha(), GHCommitState.PENDING, config.getAbsoluteUrl(), .createCommitStatus(cause.getHeadSha(), GHCommitState.PENDING, job.getAbsoluteUrl(),
public void createOrUpdateSonarQubeStatus(GHCommitState status, String statusDescription) { try { // Copy previous targetUrl in case it was set by an external system (like the CI job). String targetUrl = null; GHCommitStatus lastStatus = getCommitStatusForContext(pr, COMMIT_CONTEXT); if (lastStatus != null) { targetUrl = lastStatus.getTargetUrl(); } ghRepo.createCommitStatus(pr.getHead().getSha(), status, targetUrl, statusDescription, COMMIT_CONTEXT); } catch (FileNotFoundException e) { String msg = "Unable to set pull request status. GitHub account probably miss push permission on the repository."; if (LOG.isDebugEnabled()) { LOG.warn(msg, e); } else { LOG.warn(msg); } } catch (IOException e) { throw new IllegalStateException("Unable to update commit status", e); } }
trigger.getRemoteRepository().createCommitStatus(c.getHeadSha(), state, buildUrl, statusMsgValue, run.getParent().getFullName()); } catch (IOException ex) {
); repo.createCommitStatus(sha, state, backref, message, contextName);
@Override public void onCompleted(final DynamicBuild build, final TaskListener listener) { final String sha1 = build.getSha(); if (sha1 == null) { return; } final GHRepository repository = getGithubRepository(build); final GHCommitState state; String msg; final Result result = build.getResult(); if (result.isBetterOrEqualTo(SUCCESS)) { state = GHCommitState.SUCCESS; msg = "Success"; } else if (result.isBetterOrEqualTo(UNSTABLE)) { state = GHCommitState.FAILURE; msg = "Unstable"; } else { state = GHCommitState.FAILURE; msg = "Failed"; } if (build.isSkipped()) { msg += " - Skipped"; } try { listener.getLogger().println("setting commit status on Github for " + repository.getHtmlUrl() + "/commit/" + sha1); repository.createCommitStatus(sha1, state, build.getFullUrl(), msg, getContext(build)); } catch (final Exception e) { printErrorToBuildConsole(listener, e); } }