Branch Indexing

Branch Indexing and Discarding Old Items

Branch indexing is the scan behind a multibranch job: list branches and pull requests through the GitHub 29 API, look for a Jenkinsfile in each, create jobs for new heads, and schedule builds for heads whose commit changed. It runs on creation, on Scan Repository Now, on the periodic trigger (here every four hours, as a fallback), and on webhook events (Relaying Webhooks). After pull request #1 was merged and its branch deleted, a manual scan logged:

The branch-indexing log after the mergeShell
curl -s -u "admin:$JENKINS_TOKEN" http://localhost:32080/job/booknest/indexing/consoleText \
  | grep -E 'Checking branch|No changes|were processed|orphaned|Will not|took'
Output
  Checking branches...
    Checking branch main
No changes detected: main (still at 0ea2e02e5d098f168ec4b3a275a7a0a4b16d6306)
  1 branches were processed
  0 pull requests were processed
[Fri Sep 25 15:35:24 UTC 2026] Finished branch indexing. Indexing took 5.3 sec
Evaluating orphaned items in booknest
Will not remove Document the Jenkins pipeline (#1) as it is only #1 in the list
Will not remove Document the Jenkins pipeline (#1) because it is new

main was already at the merge commit, built by the push webhook. PR-1 became an orphaned item: disabled, its history kept. This job's Orphaned Item Strategy keeps up to 5 dead items for up to 7 days, and an item is deleted only when it exceeds both limits, hence the two "Will not remove" lines. Before the merge, a scan with this job's branch-discovery strategy logged "Ignoring SCMHead{'feature/ci-notes'} because current strategy excludes branches that ARE also filed as a pull request": the branch was built once, as PR-1, not twice.