Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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.isNotSCMSourceOwner;
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(isNotSCMSourceOwner())
.transform(reRegisterHookForJob())
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import hudson.triggers.Trigger;
import hudson.triggers.TriggerDescriptor;
import jenkins.model.ParameterizedJobMixIn;
import jenkins.scm.api.SCMSourceOwner;
import org.jenkinsci.plugins.github.extension.GHEventsSubscriber;

import javax.annotation.CheckForNull;
Expand Down Expand Up @@ -141,5 +142,18 @@ 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> isNotSCMSourceOwner() {
return new Predicate<ITEM>() {
public boolean apply(ITEM item) {
return !(item.getParent() instanceof SCMSourceOwner);
}
};
}
}