JCasC 2,791 leaves jobs to the Job DSL 1,924 plugin (3732.v9a_c49a_61a_313): Groovy scripts that describe jobs. JCasC's jobs: key runs them at startup and reload; the older way is a seed job with a Process Job DSLs step. This script creates a multibranch job per repository, with Jenkinsfiles in Source Control's settings:
// Job DSL: one multibranch job per BookNest repository
['booknest-jenkins', 'booknest-jenkins-lib'].each { repo ->
multibranchPipelineJob(repo) {
displayName("BookNest (${repo})")
branchSources {
branchSource {
source {
github {
id(repo)
repoOwner('binarybehemoth')
repository(repo)
repositoryUrl("https://github.com/binarybehemoth/${repo}")
configuredByUrl(false)
credentialsId('github-booknest')
traits {
gitHubBranchDiscovery { strategyId(1) }
gitHubPullRequestDiscovery { strategyId(1) }
}
}
}
}
}
orphanedItemStrategy {
discardOldItems { daysToKeep(7); numToKeep(5) }
}
triggers { periodicFolderTrigger { interval('4h') } }
}
}A list and a loop replace copy and paste. github { ... } comes from Job DSL's dynamic DSL, generated from the installed plugins' @Symbols; the Job DSL API Reference page lists them. Both jobs indexed at once:
C=http://localhost:32081
for job in booknest-jenkins booknest-jenkins-lib; do
curl -s -u "admin:$P" $C/job/$job/indexing/consoleText \
| grep -E "Checking branch|Jenkinsfile|criteria"
doneOutput
Checking branches...
Checking branch main
‘Jenkinsfile’ found
Met criteria
Checking branches...
Checking branch main
‘Jenkinsfile’ not found
Does not meet criteriaThe library has no Jenkinsfile yet, so its job stays empty. Job DSL in a seed job runs in the Groovy sandbox by default; from JCasC's file it is trusted like the YAML.