code: protected Function<GHRepository, GHHook> createWebhook(final URL url, final Set<GHEvent> events) {
          return new NullSafeFunction<GHRepository, GHHook>() {
              protected GHHook applyNullSafe(@Nonnull GHRepository repo) {
                  try {
                      final HashMap<String, String> config = new HashMap<>();
                      config.put("url", url.toExternalForm());
                      config.put("content_type", "json");
  
                      final Secret secret = GitHubPlugin.configuration().getHookSecretConfig().getHookSecret();
  
                      if (secret != null) {
                          config.put("secret", secret.getPlainText());
                      }
  
                      return repo.createHook("web", config, events, true);
                  } catch (IOException e) {
                      throw new GHException("Failed to create hook", e);
                  }
              }
          };
      }
docs: @param url    jenkins endpoint url
  @param events list of GH events jenkins interested in
  
  @return converter to create GH hook for given url with given events