From 48e9003a27d8fb5a706a50ea4b1a477923ae905f Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 19 Aug 2024 17:12:41 +0100 Subject: [PATCH] Prevent triggering builds on closed PRs Skips all kind of event triggers for closed PRs, rather than just for comments as per https://github.com/jenkinsci/ghprb-plugin/pull/54. Fixes: https://github.com/jenkinsci/ghprb-plugin/issues/865 --- .../org/jenkinsci/plugins/ghprb/GhprbRootAction.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRootAction.java b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRootAction.java index 9a8d39fc..66b5c220 100644 --- a/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRootAction.java +++ b/src/main/java/org/jenkinsci/plugins/ghprb/GhprbRootAction.java @@ -137,16 +137,14 @@ private void handleAction(String event, try { GitHub gh = GitHub.connectAnonymously(); - if (StringUtils.equalsIgnoreCase("issue_comment", event)) { + if (state == GHIssueState.CLOSED) { + LOGGER.log(Level.INFO, "Skip ''{0}'' event on closed PR", event); + return; + } else if (StringUtils.equalsIgnoreCase("issue_comment", event)) { comment = getIssueComment(payload, gh); GHIssueState state = comment.getIssue().getState(); - if (state == GHIssueState.CLOSED) { - LOGGER.log(Level.INFO, "Skip comment on closed PR"); - return; - } - if (!comment.getIssue().isPullRequest()) { LOGGER.log(Level.INFO, "Skip comment on Issue"); return;