-
Bug
-
Resolution: Done
-
Minor
-
None
The DefaultPushGHEventSubscriber provides an extension point for "other plugins [that] may be interested in listening for these updates" (GitHubWebHook.Listener). However, the only information those other plugins can receive is the name of the pusher and the repository URL.
It'd be useful to also give the GHEvent, the string payload, or both to the listener, so that the extension can make useful decisions about what to do on the push event. As it is, a listener can know a push happened on a repo, but not what was pushed.
This restricts the ability of the listeners to perform useful tasks such as only updating a single branch (e.g. https://github.com/jenkinsci/github-branch-source-plugin/blob/master@%7B2016-09-02%7D/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubWebhookListenerImpl.java#L49) - seems to be the root cause behind major missing functionality in github-branch-source, for instance
GitHubWebHook.Listener is a deprecated extension point and not recommended to use. It exists only for backward compatibility.
If you want to receive more events and payload, then you should extend this class:
https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github/extension/GHEventsSubscriber.java
The working example is DefaultPushGHEventSubscriber and https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github/webhook/subscriber/PingGHEventSubscriber.java
One more example can be found here:
https://github.com/KostyaSha/github-integration-plugin/blob/master/github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/webhook/GHPullRequestSubscriber.java