jenkinsci / jenkinsci/configuration-as-code-plugin

Jenkins is not starting in installation phase - bitbucket rate limiting error

Open
#2,511 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
2.8k
Forks
756
Avg merge
9h 47m
Merged PRs (30d)
10

Description

### Description

Sometimes, jenkins is not starting and shutting down in organization folder scan step. I found out that getting rate limiting error from bitbucket server because of many requests from jenkins.

How can I make sure not to scan all branches when I start the instance. I am using below config:

organizationFolder('my-bitbucket') {
description("Bitbucket org folder configured with JCasC")
displayName('project')
organizations {
bitbucket {
serverUrl("https://bitbucket.org")
repoOwner("project")
credentialsId("bitbucket")
}
}
configure { node ->
def traits = node / navigators / 'com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator' / traits
traits << 'com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait' {
strategyId('1')
}
traits << 'jenkins.scm.impl.trait.WildcardSCMSourceFilterTrait' {
includes('project1 project2 project3')
}
traits << 'jenkins.scm.impl.trait.WildcardSCMHeadFilterTrait' {
includes('alpha develop staging master')
}
traits << 'com.cloudbees.jenkins.plugins.bitbucket.OriginPullRequestDiscoveryTrait' {
strategyId('1')
}
traits << 'com.cloudbees.jenkins.plugins.bitbucket.ForkPullRequestDiscoveryTrait' {
strategyId('1')
trustID('1')
}
}
projectFactories {
workflowMultiBranchProjectFactory {
scriptPath 'Jenkinsfile'
}
}
orphanedItemStrategy {
discardOldItems {
daysToKeep(-1)
numToKeep(-1)
}
}
buildStrategies {
buildAllBranches {
strategies {
skipInitialBuildOnFirstBranchIndexing()
}
}
}
}

Jenkins shutting down after logs like this:

2024-06-14 20:23:27.972+0000 [id=30] INFO c.c.h.p.folder.AbstractFolder#lambda$onLoad$4: Loading job bitbucket-cluster/project1 (593.3%)

These are the logs we got from bitbucket for rate limiting:

/2.0/repositories/My-project/project1/src/5e7647700b366aab5e254312fba0127757a7e0be/Jenkinsfile - 1034
/2.0/repositories/My-project/project1/pullrequests?page=1&pagelen=50 - 947
/2.0/repositories/My-project/project2/src/6dbba8a547047884f3aff794910abc522cc7e691/Jenkinsfile - 912
/2.0/repositories/My-project/project2/pullrequests?page=2&pagelen=50 - 346
/2.0/repositories/My-project/project2/pullrequests?page=1&pagelen=50 - 153
/2.0/repositories/My-project/project1/refs/branches/develop - 10

As you can see, it's hitting PRs and different branches those we don't even have in above config.

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Start by reproducing organization-folder indexing with the supplied JCasC configure block and compare the configured branch and pull-request traits with the Bitbucket request logs. Done means explaining why excluded branches or pull requests are scanned and identifying a scoped change or configuration correction.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, java
Domain
ci-cd, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.