Skip to content

Add skipScriptPathCheck flag to WorkflowBranchProjectFactory - #580

Open
das7pad wants to merge 1 commit into
jenkinsci:masterfrom
overleaf:jpa-skipScriptPathCheck
Open

Add skipScriptPathCheck flag to WorkflowBranchProjectFactory#580
das7pad wants to merge 1 commit into
jenkinsci:masterfrom
overleaf:jpa-skipScriptPathCheck

Conversation

@das7pad

@das7pad das7pad commented Aug 24, 2026

Copy link
Copy Markdown

WorkflowBranchProjectFactory#getSCMSourceCriteria(SCMSource) currently returns an anonymous SCMSourceCriteria that always calls probe.stat(scriptPath) to verify the Jenkinsfile exists at the head being discovered. For GitHubSCMSource this becomes a GET /repos/{o}/{r}/contents/{dir}/?ref=... API call per source per event.

When many multibranch jobs watch the same repo (Overleaf has ~70), each one configures its own per-service scriptPath (e.g. services/web/Jenkinsfile), so every push event causes 70 contents API calls -- each to a different directory, so the on-disk OkHttp cache and the EventScopedCache patch don't deduplicate them.

This patch adds an opt-in boolean field skipScriptPathCheck. When set, getSCMSourceCriteria() returns a trivial criteria that accepts every head without probing. Builds that fail to find the Jenkinsfile at execution time will still fail noisily -- which is the right behaviour for setups where the calling pipeline (e.g. a coordinator) guarantees the Jenkinsfile exists before triggering downstream jobs.

The flag is opt-in (default false), so existing jobs are unaffected.

Testing done

We've been using this patch to cut down API calls notably for our production Jenkins instance over the past 3 months. More patches will follow.

All of our pipelines are generated programatically, so that's what's implemented here.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

WorkflowBranchProjectFactory#getSCMSourceCriteria(SCMSource) currently
returns an anonymous SCMSourceCriteria that always calls probe.stat(scriptPath)
to verify the Jenkinsfile exists at the head being discovered. For
GitHubSCMSource this becomes a GET /repos/{o}/{r}/contents/{dir}/?ref=...
API call per source per event.

When many multibranch jobs watch the same repo (Overleaf has ~70), each one
configures its own per-service scriptPath (e.g. services/web/Jenkinsfile),
so every push event causes 70 contents API calls -- each to a different
directory, so the on-disk OkHttp cache and the EventScopedCache patch don't
deduplicate them.

This patch adds an opt-in boolean field `skipScriptPathCheck`. When set,
getSCMSourceCriteria() returns a trivial criteria that accepts every head
without probing. Builds that fail to find the Jenkinsfile at execution time
will still fail noisily -- which is the right behaviour for setups where
the calling pipeline (e.g. a coordinator) guarantees the Jenkinsfile exists
before triggering downstream jobs.

The flag is opt-in (default false), so existing jobs are unaffected.
@das7pad
das7pad requested a review from a team as a code owner August 24, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant