Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/com/cloudbees/jenkins/GitHubWebHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import static org.jenkinsci.plugins.github.util.FluentIterableWrapper.from;
import static org.jenkinsci.plugins.github.util.JobInfoHelpers.isAlive;
import static org.jenkinsci.plugins.github.util.JobInfoHelpers.isBuildable;
import static org.jenkinsci.plugins.github.util.JobInfoHelpers.isNotChild;
import static org.jenkinsci.plugins.github.webhook.WebhookManager.forHookUrl;


Expand Down Expand Up @@ -104,6 +105,7 @@ public List<Item> reRegisterAllHooks() {
return from(getJenkinsInstance().getAllItems(Item.class))
.filter(isBuildable())
.filter(isAlive())
.filter(isNotChild())
.transform(reRegisterHookForJob())
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,19 @@ protected Job asJob() {
}
};
}

/**
* Can be useful to ignore child jobs on reregistering hooks
*
* @return predicate with true on apply if item is not a child of WorkflowMultiBranchProject
*/
public static <ITEM extends Item> Predicate<ITEM> isNotChild() {
return new Predicate<ITEM>() {
public boolean apply(ITEM item) {
return !(item.getParent().getClass().getName().equals("org.jenkinsci.plugins.workflow.multibranch"
+ ".WorkflowMultiBranchProject"));
}
};
}
}