Managing Views and Folders
1. Creating List Views
List views in Jenkins provide a way to organize and filter jobs based on specific criteria. They help manage large numbers of jobs by grouping them into logical sets.
| Property | Description | Default Value |
|---|---|---|
| View Name | Name of the view to be created | None |
| View Type | Type of view to create (e.g., List View, Dashboard View) | List View |
Example: Creating a List View via UI
1. Navigate to Jenkins dashboard
2. Click on "New View" in the left sidebar
3. Enter a name for your view (e.g., "My-Jobs-View")
4. Select "List View" from the view type options
5. Click "OK"
6. Configure job inclusion criteria if needed
7. Save the view configuration
Example: Creating a List View via Jenkins API
const Jenkins = require('jenkins');
const jenkins = new Jenkins({ baseUrl: 'http://localhost:8080', crumbIssuer: true });
jenkins.view.create('My-Jobs-View', {
name: 'My-Jobs-View',
jobs: [
{ name: 'job1' },
{ name: 'job2' }
]
});
2. Creating My Views
Example: Create a New View
curl -X POST "http://jenkins.example.com/view/MyView/createView" \
-H "Content-Type: application/xml" \
-d "<hudson.model.ListView><name>MyView</name><filterExecutors>false</filterExecutors><filterQueue>false</filterQueue></hudson.model.ListView>"
| Property | Description | Default |
|---|---|---|
| name | Name of the view | None |
| filterExecutors | Filter executors based on job permissions | false |
| filterQueue | Filter queue based on job permissions | false |
Note: Views can be created via the Jenkins UI or REST API. The example uses a POST request to create a ListView.
Warning: Ensure that the user has appropriate permissions to create views in Jenkins.
3. Using Build Pipeline View
Example: Configuring Build Pipeline View
<view>
<name>BuildPipelineView</name>
<buildPipelineView>
<name>BuildPipelineView</name>
<title>Build Pipeline View</title>
<jobNames>
<string>job1</string>
<string>job2</string>
</jobNames>
</buildPipelineView>
</view>
| Property | Description | Default Value |
|---|---|---|
| name | Name of the view | BuildPipelineView |
| title | Title displayed in the view | Build Pipeline View |
| jobNames | List of jobs to include in the pipeline view | Empty list |
Note: The Build Pipeline View plugin must be installed to use this view type.
Warning: The Build Pipeline View is deprecated as of Jenkins 2.307 and will be removed in future versions.
4. Creating Dashboard Views
| Property | Value | Description |
|---|---|---|
| view.name | dashboard-view |
Name of the view to be created |
| view.type | DashboardView |
Type of view to create (Dashboard View) |
| view.description | Dashboard for build status |
Description of the view (optional) |
Example: Creating a Dashboard View via Jenkins UI
1. Go to Jenkins dashboard
2. Click "New View"
3. Enter view name (e.g., "Build Dashboard")
4. Select "Dashboard View"
5. Click "OK"
6. Configure view settings (e.g., add jobs, set refresh interval)
7. Save the view
Example: Creating a Dashboard View via Jenkins Script
import jenkins.model.Jenkins
import hudson.model.View
import hudson.plugins.view.dashboard.Dashboard
def jenkins = Jenkins.instance
def viewName = "Build Dashboard"
def description = "Dashboard for build status"
def dashboardView = new Dashboard(viewName, description)
jenkins.addView(dashboardView)
jenkins.save()
Note: Dashboard Views in Jenkins allow for a customizable dashboard layout to display job status, build history, and other relevant information in a single view.
5. Filtering Jobs in Views
| Filter Type | Description | Configuration | Notes |
|---|---|---|---|
| Job Name | Filter jobs by name pattern | jobNamePattern |
Supports wildcards like * and ? |
| Status | Filter jobs by build status (success, failure, unstable) | statusFilter |
Can be set to all, success, failure, or unstable |
| Build Time | Filter jobs by last build time | buildTimeFilter |
Can filter by last build within a time range (e.g., last 24 hours) |
| Job Type | Filter jobs by type (e.g., Freestyle, Pipeline) | jobTypeFilter |
Supports freestyle, pipeline, and matrix |
Example: Configuring Job Name Filter
def view = new ListView("MyView")
view.jobNames = ["*Build*", "Test-*"]
view.save()
Example: Using Status Filter
def view = new ListView("FailedJobs")
view.jobNames = ["*Build*"]
view.statusFilter = "failure"
view.save()
Note: Filters can be combined to create more complex views. For example, you can filter by job name and status simultaneously.
6. Creating Folders for Organization
Folders in Jenkins help organize jobs and pipelines into logical groups, improving manageability in large environments.
| Property | Description | Default Value |
|---|---|---|
| Folder Name | Unique identifier for the folder within Jenkins | None |
| Folder Description | Optional description to explain the folder's purpose | None |
Example: Creating a Folder via UI
1. Navigate to Jenkins Dashboard
2. Click "New Item"
3. Enter folder name (e.g., "Project-A")
4. Select "Folder" as item type
5. Click "OK"
6. Configure folder settings if needed
Example: Creating a Folder via Jenkins CLI
java -jar jenkins-cli.jar -s http://localhost:8080/ -auth <credentials> create-job "folder-name" < job-config.xml
Note: Folders can be nested to create hierarchical organization.
7. Configuring Folder Properties
| Property | Value | Description |
|---|---|---|
| displayName | "My Folder" |
Display name for the folder in Jenkins UI |
| description | "A folder containing build jobs" |
Optional description of the folder's purpose |
| folderCompression | "none" |
Compression method for folder contents (none, gzip) |
Example: Folder Configuration
import jenkins.model.Jenkins
import hudson.model.Folder
def folder = new Folder(Jenkins.instance, "my-folder")
folder.setDisplayName("My Project Folder")
folder.setDescription("Contains all project builds")
folder.save()
Note: Folder properties can be managed via the Jenkins UI or programmatically using the Jenkins API.
8. Using Folder-Level Credentials
| Property | Value | Description |
|---|---|---|
| folder.path | my-folder |
Path to the folder where credentials are managed |
| credential.id | my-cred-id |
Unique identifier for the credential within the folder scope |
| credential.type | usernamePassword |
Type of credential (e.g., username/password, SSH key) |
Example: Configure Folder-Level Credential
def folder = Jenkins.instance.getFolder('my-folder')
def credential = new UsernamePasswordCredentialsImpl(
CredentialsScope.GLOBAL,
'my-cred-id',
'Description of credential',
'username',
'password'
)
folder.addProperty(new CredentialsProvider.CredentialsProperty(credential))
Note: Folder-level credentials are isolated to the folder scope and not inherited from parent folders or global settings.
9. Nesting Folders
Nesting folders in Jenkins allows you to organize jobs and views hierarchically, improving manageability in large environments.
| Property | Description | Notes |
|---|---|---|
| Folder Name | Name of the folder | Must be unique within the parent scope |
| Parent Path | Path to the parent folder | Can be nested up to 10 levels deep |
| Folder Permissions | Access control for the folder | Can inherit or override parent permissions |
Example: Creating a Nested Folder
curl -X POST "http://jenkins.example.com/job/Project/job/Team1/job/NestedFolder/createItem" \
-H "Content-Type: application/xml" \
-d "<hudson.model.FreeStyleProject><name>NestedFolder</name></hudson.model.FreeStyleProject>"
Note: Folder nesting is supported via the
Folder plugin. Ensure it's installed and enabled.
Warning: Deep nesting can impact performance and UI responsiveness. Use with caution in large setups.
10. Managing View Permissions
| Permission | Description | Default Granted To |
|---|---|---|
| View.Read | Allows reading/viewing of views and their configurations | All users with access to the Jenkins instance |
| View.Create | Allows creating new views | Users with Job.Create or administrator role |
| View.Delete | Allows deleting views | Users with Job.Delete or administrator role |
| View.Configure | Allows configuring views (e.g., adding jobs to a view) | Users with Job.Configure or administrator role |
| View.Discover | Allows users to discover views they do not have direct access to | All authenticated users |
Example: Configure View Permissions via UI
1. Go to Jenkins Dashboard
2. Click on "Manage Jenkins"
3. Select "Configure Global Security"
4. Under "Authorization", select "Matrix-based security"
5. Add user or group and assign appropriate permissions
Note: Permissions can also be managed using Jenkins Script Console or by editing
config.xml directly.