Skip to content

Commit

Permalink
Prevent triggering builds on closed PRs
Browse files Browse the repository at this point in the history
Skips all kind of event triggers for closed PRs, rather than just for comments as per jenkinsci/ghprb-plugin#54.

Fixes: jenkinsci/ghprb-plugin#865
  • Loading branch information
JackPGreen committed Aug 19, 2024
1 parent f8818b4 commit 48e9003
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/org/jenkinsci/plugins/ghprb/GhprbRootAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 48e9003

Please sign in to comment.