public void unregisterFor ( GitHubRepositoryName name , List < GitHubRepositoryName > aliveRepos ) { try { GHRepository repo = checkNotNull ( from ( name . resolve ( allowedToManageHooks ( ) ) ) . firstMatch ( withAdminAccess ( ) ) . orNull ( ) , "There are no credentials with admin access to manage hooks on %s" , name ) ; LOGGER . debug ( "Check {} for redundant hooks..." , repo ) ; Predicate < GHHook > predicate = aliveRepos . contains ( name ) ? serviceWebhookFor ( endpoint ) // permanently clear service hooks (JENKINS-28138) : or ( serviceWebhookFor ( endpoint ) , webhookFor ( endpoint ) ) ; from ( fetchHooks ( ) . apply ( repo ) ) . filter ( predicate ) . filter ( deleteWebhook ( ) ) . filter ( log ( "Deleted hook" ) ) . toList ( ) ; } catch ( Throwable t ) { LOGGER . warn ( "Failed to remove hook from {}" , name , t ) ; GitHubHookRegisterProblemMonitor . get ( ) . registerProblem ( name , t ) ; } }
Used to cleanup old hooks in case of removed or reconfigured trigger since JENKINS - 28138 this method permanently removes service hooks