@@ -141,27 +141,31 @@ public Set<GitHubRepositoryName> getGitHubRepositories() {
141
141
public void start (AbstractProject <?,?> project , boolean newInstance ) {
142
142
super .start (project , newInstance );
143
143
if (newInstance && getDescriptor ().isManageHook ()) {
144
- // make sure we have hooks installed. do this lazily to avoid blocking the UI thread.
145
- final Collection <GitHubRepositoryName > names = GitHubRepositoryNameContributor .parseAssociatedNames (job );
146
-
147
- getDescriptor ().queue .execute (new Runnable () {
148
- public void run () {
149
- LOGGER .log (Level .INFO , "Adding GitHub webhooks for {0}" , names );
150
-
151
- for (GitHubRepositoryName name : names ) {
152
- for (GHRepository repo : name .resolve ()) {
153
- try {
154
- if (createJenkinsHook (repo , getDescriptor ().getHookUrl ())) {
155
- break ;
156
- }
157
- } catch (Throwable e ) {
158
- LOGGER .log (Level .WARNING , "Failed to add GitHub webhook for " +name , e );
144
+ registerHooks ();
145
+ }
146
+ }
147
+
148
+ public void registerHooks () {
149
+ // make sure we have hooks installed. do this lazily to avoid blocking the UI thread.
150
+ final Collection <GitHubRepositoryName > names = GitHubRepositoryNameContributor .parseAssociatedNames (job );
151
+
152
+ getDescriptor ().queue .execute (new Runnable () {
153
+ public void run () {
154
+ LOGGER .log (Level .INFO , "Adding GitHub webhooks for {0}" , names );
155
+
156
+ for (GitHubRepositoryName name : names ) {
157
+ for (GHRepository repo : name .resolve ()) {
158
+ try {
159
+ if (createJenkinsHook (repo , getDescriptor ().getHookUrl ())) {
160
+ break ;
159
161
}
162
+ } catch (Throwable e ) {
163
+ LOGGER .log (Level .WARNING , "Failed to add GitHub webhook for " +name , e );
160
164
}
161
165
}
162
166
}
163
- });
164
- }
167
+ }
168
+ });
165
169
}
166
170
167
171
private boolean createJenkinsHook (GHRepository repo , URL url ) {
0 commit comments