0
0
Jenkinsdevops~5 mins

Dashboard views configuration in Jenkins - Commands & Configuration

Choose your learning style9 modes available
Introduction
Jenkins dashboard views help organize and display jobs in groups. This makes it easier to find and monitor related jobs without scrolling through a long list.
When you have many Jenkins jobs and want to group them by project or team.
When you want to create a custom view showing only jobs that are currently failing.
When you want to separate jobs by type, like build jobs and deployment jobs.
When you want to share a focused dashboard with your team showing only relevant jobs.
When you want to quickly see the status of a subset of jobs without distractions.
Config File - dashboard-view-config.xml
dashboard-view-config.xml
<hudson.plugins.view.dashboard.DashboardView plugin="dashboard-view@2.14">
  <name>MyDashboard</name>
  <filterExecutors>false</filterExecutors>
  <filterQueue>false</filterQueue>
  <properties class="hudson.model.View$PropertyList"/>
  <columns>
    <hudson.plugins.view.dashboard.DashboardColumn/>
    <hudson.plugins.view.dashboard.StatusColumn/>
    <hudson.plugins.view.dashboard.WeatherColumn/>
  </columns>
  <portlets>
    <hudson.plugins.view.dashboard.AllBuildsPortlet>
      <name>All Builds</name>
      <width>full</width>
    </hudson.plugins.view.dashboard.AllBuildsPortlet>
    <hudson.plugins.view.dashboard.BuildStatisticsPortlet>
      <name>Build Statistics</name>
      <width>half</width>
    </hudson.plugins.view.dashboard.BuildStatisticsPortlet>
  </portlets>
  <jobFilters>
    <hudson.plugins.view.dashboard.IncludeJobFilter>
      <includeRegex>.*</includeRegex>
    </hudson.plugins.view.dashboard.IncludeJobFilter>
  </jobFilters>
</hudson.plugins.view.dashboard.DashboardView>

This XML file configures a Jenkins dashboard view named MyDashboard. It defines columns to show job status and weather icons. It adds portlets to display all builds and build statistics. The job filter includes all jobs with .* regex.

This file can be used to create or update a dashboard view in Jenkins by importing or placing it in the Jenkins views configuration.

Commands
This command uses Jenkins CLI to create a new dashboard view named 'MyDashboard' using the configuration file. It connects to the Jenkins server at localhost on port 8080.
Terminal
java -jar jenkins-cli.jar -s http://localhost:8080 create-view MyDashboard < dashboard-view-config.xml
Expected OutputExpected
View 'MyDashboard' created successfully
-s - Specifies the Jenkins server URL
This command lists all views configured in Jenkins to verify that 'MyDashboard' was created.
Terminal
java -jar jenkins-cli.jar -s http://localhost:8080 list-views
Expected OutputExpected
All MyDashboard
-s - Specifies the Jenkins server URL
This command retrieves the configuration of the 'MyDashboard' view to confirm its settings.
Terminal
java -jar jenkins-cli.jar -s http://localhost:8080 get-view MyDashboard
Expected OutputExpected
<hudson.plugins.view.dashboard.DashboardView plugin="dashboard-view@2.14"> <name>MyDashboard</name> <filterExecutors>false</filterExecutors> <filterQueue>false</filterQueue> <properties class="hudson.model.View$PropertyList"/> <columns> <hudson.plugins.view.dashboard.DashboardColumn/> <hudson.plugins.view.dashboard.StatusColumn/> <hudson.plugins.view.dashboard.WeatherColumn/> </columns> <portlets> <hudson.plugins.view.dashboard.AllBuildsPortlet> <name>All Builds</name> <width>full</width> </hudson.plugins.view.dashboard.AllBuildsPortlet> <hudson.plugins.view.dashboard.BuildStatisticsPortlet> <name>Build Statistics</name> <width>half</width> </hudson.plugins.view.dashboard.BuildStatisticsPortlet> </portlets> <jobFilters> <hudson.plugins.view.dashboard.IncludeJobFilter> <includeRegex>.*</includeRegex> </hudson.plugins.view.dashboard.IncludeJobFilter> </jobFilters> </hudson.plugins.view.dashboard.DashboardView>
-s - Specifies the Jenkins server URL
Key Concept

If you remember nothing else from this pattern, remember: Jenkins dashboard views let you group and display jobs in custom ways to keep your workspace organized and focused.

Common Mistakes
Trying to create a dashboard view without the dashboard-view plugin installed.
The dashboard view features depend on the plugin; without it, Jenkins will reject the configuration.
Install the 'Dashboard View' plugin from Jenkins plugin manager before creating dashboard views.
Using incorrect XML syntax or missing required tags in the dashboard view config file.
Jenkins will fail to create or update the view due to invalid configuration format.
Use a valid XML configuration file exported from Jenkins or carefully follow the plugin's XML schema.
Not specifying the Jenkins server URL (-s flag) in CLI commands.
The CLI will not know which Jenkins instance to connect to and will fail.
Always include the -s flag with the correct Jenkins URL when running CLI commands.
Summary
Create a dashboard view by preparing a valid XML configuration file.
Use Jenkins CLI with the create-view command to add the dashboard view.
Verify the view creation by listing views and retrieving the view configuration.