title: Should branch indexing for Multibranch Pipeline jobs be triggered automatically by webhooks?
body: <p>I've set up a number of Multibranch Pipeline jobs in Jenkins (running 2.46.2 LTS, Branch API 2.0.8, GitHub Branch Source 2.0.5, and Pipeline Multibranch 2.14) and have just noted that branch indexing -- and thus any cleanup of old branches -- does not appear to be triggered by the webhook calls from GitHub. It only appears to be triggered if someone manually clicks the &quot;Scan Repository Now&quot; link, or if the job configuration in Jenkins is re-saved. I'm using the timestamp shown in the &quot;Scan Repository Log&quot; page as an indication of when the branch indexing occurs.</p>
  <p>It seems that new branches or changes to existing ones are being detected correctly and built, so the webhooks from source control (GitHub) are working, but was surprised that this wasn't also triggering the branch indexing and thus the old branch cleanup. I just can't tell from the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Multibranch+Plugin" rel="nofollow noreferrer">documentation</a> whether this is correct and expected behavior or if something is incorrect in my setup.</p>
  <p>I note that the help text for the &quot;Periodically if not otherwise run&quot; setting says:</p>
  <blockquote>
  <p>Some kinds of folders are reindexed automatically and immediately upon receipt of an external event. For example, a multi-branch project will recheck its SCM repository for new or removed or modified branches when it receives an SCM change notification. (Push notification may be configured as per the SCM plugin used for each respective branch source.) Such notifications can occasionally be unreliable, however, or Jenkins might not even be running to receive them. In some cases no immediate notification is even possible, for example because Jenkins is behind a firewall and can only poll an external system.</p>
  <p>This trigger allows for a periodic fallback, but when necessary. If no indexing has been performed in the specified interval, then an indexing will be scheduled. For example, in the case of a multi-branch project, if the source control system is not configured for push notification, set a short interval (most people will pick between 15 minutes and 1 hour). If the source control system is configured for push notification, set an interval that corresponds to the maximum acceptable delay in the event of a lost push notification as the last commit of the day. (Subsequent commits should trigger indexing anyway and result in the commit being picked up, so most people will pick between 4 hours and 1 day.)</p>
  </blockquote>
  <p>This certainly implies that indexing of a Multibranch Pipeline job should be re-triggered by branch events (e.g., pushes from GitHub via webhook), but the timestamp on my indexing log seems to belie that.</p>
  <p>So, is what I'm observing the intended behavior? If so, and I want a regular cleanup of old branches, do I need to select the &quot;Periodically if not otherwise run&quot; checkbox under &quot;Scan repository triggers&quot;? Or is there something wrong with my setup, which is preventing it from working as intended?</p>