Add skipScriptPathCheck flag to WorkflowBranchProjectFactory - #580
Open
das7pad wants to merge 1 commit into
Open
Add skipScriptPathCheck flag to WorkflowBranchProjectFactory#580das7pad wants to merge 1 commit into
das7pad wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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