public GHHook createWebHook(URL url, Collection<GHEvent> events) throws IOException { return createHook("web",Collections.singletonMap("url",url.toExternalForm()),events,true); }
public GHHook createWebHook(URL url, Collection<GHEvent> events) throws IOException { return createHook("web",Collections.singletonMap("url",url.toExternalForm()),events,true); }
public GHHook createWebHook(URL url, Collection<GHEvent> events) throws IOException { return createHook("web",Collections.singletonMap("url",url.toExternalForm()),events,true); }
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); } } };
public boolean createHook() { try { // Avoid a race to update the hooks in a repo (we could end up with // multiple hooks). Lock on before we try this synchronized (CREATE_HOOK_LOCK) { if (hookExist()) { return true; } Map<String, String> config = new HashMap<String, String>(); String secret = getSecret(); config.put("url", new URL(getHookUrl()).toExternalForm()); config.put("insecure_ssl", "0"); if (!StringUtils.isEmpty(secret)) { config.put("secret", secret); } getGitHubRepo().createHook("web", config, HOOK_EVENTS, true); return true; } } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Could not create web hook for repository {0}. " + "Does the user (from global configuration) have admin rights to the repository?", reponame); return false; } }
public void addHook(final String accessToken, final String user) throws IOException { String githubCallbackUrl = getSetupConfig().getGithubCallbackUrl(); if (!githubCallbackUrl.endsWith("/")) { githubCallbackUrl = githubCallbackUrl + "/"; } final Map<String, String> params = ImmutableMap.of("url", githubCallbackUrl); final List<GHEvent> events = Arrays.asList(GHEvent.PUSH, GHEvent.PULL_REQUEST); this.githubAccessTokenRepository.put(getRepository().getHtmlUrl().toExternalForm(), accessToken, user); removeExistingHook(githubCallbackUrl); getRepository().createHook("web", params, events, true); }