Folders
Folders organize jobs into groups and let you scope credentials and permissions to a team or project.
Folders (from the CloudBees Folders plugin, included in most setups) let you group related jobs together, like directories on a filesystem.
Why folders help
- Organization — keep each team or project's jobs together.
- Scoped credentials — store secrets inside a folder so only that folder's jobs can use them.
- Scoped permissions — grant a team access to just their folder.
Naming
Jobs inside a folder are addressed with a path, like team-a/backend/deploy.
Example
# Folder structure example:
#
# team-payments/
# |-- api-build
# |-- api-deploy
# +-- (folder credentials: db-password, api-key)
#
# team-web/
# |-- site-build
# +-- site-deploy
#
# Credentials in team-payments are invisible to team-web.When to use it
- A DevOps team creates a Frontend folder and a Backend folder so each team sees only their own pipelines on the dashboard.
- Credentials for the payments service are scoped to the Payments folder so only pipelines inside that folder can use them.
- A shared-services team uses a folder to group all infrastructure pipelines and applies its own role-based access to that folder.
More examples
Create a folder via Job DSL
Creates a 'backend' folder and a pipeline job inside it using the Jenkins Job DSL plugin.
// In a Job DSL seed job
folder('backend') {
description('All backend service pipelines')
}
pipelineJob('backend/api-service') {
definition {
cpsScm {
scm {
git {
remote { url('https://github.com/org/api.git') }
branch('main')
}
}
}
}
}Folder-scoped credential reference
References a credential scoped to the Payments folder; the credential is invisible to jobs outside the folder.
// Inside a pipeline that lives in the 'payments' folder
pipeline {
agent any
environment {
// This credential exists only in the 'payments' folder scope
STRIPE_KEY = credentials('stripe-secret-key')
}
stages {
stage('Charge') { steps { sh './charge.sh' } }
}
}Folder REST API path
Shows the nested /job/folder/job/item REST API path used to interact with jobs inside Jenkins folders.
# Jobs inside folders are accessed via nested paths
curl -s \
http://localhost:8080/job/backend/job/api-service/api/json \
--user admin:$TOKEN \
| python3 -m json.tool
Discussion