public void createOrUpdateGlobalComments(@Nullable String markup) { try { boolean found = findAndDeleteOthers(markup); if (markup != null && !found) { pr.comment(markup); } } catch (IOException e) { throw new IllegalStateException("Unable to read the pull request comments", e); } }
public void addComment(int id, String comment, Run<?, ?> build, TaskListener listener) { if (comment.trim().isEmpty()) { return; } if (build != null && listener != null) { try { comment = build.getEnvironment(listener).expand(comment); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error", e); } } try { GHRepository repo = getGitHubRepo(); GHPullRequest pr = repo.getPullRequest(id); pr.comment(comment); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Could not add comment to pull request #" + id + ": '" + comment + "'", ex); } }
public static void addComment(final int id, final String comment, final Run<?, ?> run, final TaskListener listener) { if (comment.trim().isEmpty()) { return; } String finalComment = comment; if (nonNull(run) && nonNull(listener)) { try { finalComment = run.getEnvironment(listener).expand(comment); } catch (Exception e) { LOG.error("Error", e); } } try { if (nonNull(run)) { final GitHubPRTrigger trigger = ghPRTriggerFromRun(run); GHRepository ghRepository = trigger.getRemoteRepository(); ghRepository.getPullRequest(id).comment(finalComment); } } catch (IOException ex) { LOG.error("Couldn't add comment to pull request #{}: '{}'", id, finalComment, ex); } }
protected void addProwComment(CommandContext context, GHPullRequest pullRequest) throws IOException { String prowCommand = context.getConfiguration().getProwPRCommand(); if (Strings.isNotBlank(prowCommand)) { pullRequest.comment(prowCommand); } }
private void addIssueClosedCommentIfRequired(CommandContext context, GHPullRequest pullRequest, boolean create) { GHIssue issue = context.getIssue(); if (issue == null) { return; } if (!create) { // avoid duplicate comment try { List<GHIssueComment> comments = pullRequest.getComments(); for (GHIssueComment comment : comments) { String body = comment.getBody(); if (body != null && body.startsWith(PullRequests.ISSUE_LINK_COMMENT)) { return; } } } catch (IOException e) { // ignore } } try { pullRequest.comment(PullRequests.ISSUE_LINK_COMMENT + " " + issue.getHtmlUrl() + PullRequests.ISSUE_LINK_COMMENT_SUFFIX); } catch (IOException e) { // ignore } }
private void addIssueClosedCommentIfRequired(CommandContext context, GHPullRequest pullRequest, boolean create) { GHIssue issue = context.getIssue(); if (issue == null) { return; } if (!create) { // avoid duplicate comment try { List<GHIssueComment> comments = pullRequest.getComments(); for (GHIssueComment comment : comments) { String body = comment.getBody(); if (body != null && body.startsWith(PullRequests.ISSUE_LINK_COMMENT)) { return; } } } catch (IOException e) { // ignore } } try { pullRequest.comment(PullRequests.ISSUE_LINK_COMMENT + " " + issue.getHtmlUrl() + PullRequests.ISSUE_LINK_COMMENT_SUFFIX); } catch (IOException e) { // ignore } }
context.info(LOG, configuration.colored(Configuration.COLOR_PENDING, "Created pull request " + pullRequest.getHtmlUrl())); pullRequest.comment(commandComment); addIssueClosedCommentIfRequired(context, pullRequest, true); pullRequest.setLabels(configuration.getGithubPullRequestLabel()); return; pullRequest.comment("[UpdateBot](https://github.com/fabric8io/updatebot) rebasing due to merge conflicts"); pullRequest.comment(commandComment);
context.info(LOG, configuration.colored(Configuration.COLOR_PENDING, "Created pull request " + pullRequest.getHtmlUrl())); pullRequest.comment(commandComment); pullRequest.comment(commandComment); return; pullRequest.comment("[UpdateBot](https://github.com/jenkins-x/updatebot) rebasing due to merge conflicts"); pullRequest.comment(commandComment);