Skip to content

Commit

Permalink
Prevent triggering builds on closed PRs [DI-248] (#40)
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.

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/ghprb-plugin#865,
[DI-248](https://hazelcast.atlassian.net/browse/DI-248)

Post-merge actions:
- [ ] Deploy in Jenkins
- [ ] Test
- [ ] Raise upstream PR

[DI-248]:
https://hazelcast.atlassian.net/browse/DI-248?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
JackPGreen authored Sep 4, 2024
1 parent f8818b4 commit 0d8b1fe
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 0d8b1fe

Please sign in to comment.