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#54.

I've not added a test to cover this, as there's no existing test coverage for `pull_request` events in `org.jenkinsci.plugins.ghprb.GhprbRootActionTest`, nor is there any example payloads in `org.jenkinsci.plugins.ghprb.GhprbTestUtil`.

Fixes: jenkinsci#865
  • Loading branch information
JackPGreen authored Sep 5, 2024
1 parent ebd6df7 commit 8645211
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ private void handleAction(String event,
} else if (StringUtils.equalsIgnoreCase("pull_request", event)) {

pr = getPullRequest(payload, gh);
GHIssueState state = pr.getPullRequest().getState();

if (state == GHIssueState.CLOSED) {
LOGGER.log(Level.INFO, "Skip ''{0}'' event on closed PR", event);
return;
}

repoName = pr.getRepository().getFullName();

LOGGER.log(Level.INFO, "Checking PR #{1} for {0}", new Object[] {repoName, pr.getNumber()});
Expand Down

0 comments on commit 8645211

Please sign in to comment.