A Jenkins utility job for analyzing and reporting the configuration of other freestyle jobs/projects
The configuration complexity of Jenkins freestyle jobs has increased, especially as we are now introducing dynamic parameter behavior (using the Active Choices and other similar Jenkins plugins). There is a need for a quick and concise way to review and access project parameters, builders, publishers, and Groovy code and plugin dependencies.
This utility Jenkins job allows you to select one of the jobs on your Jenkins server, analyze its configuration, and create a concise report of the job's main elements (parameters, scm, builders, publishers, build-wrappers) as well as the Groovy code, scripts and plugin dependencies.
By examining a JOB_CONFIG_ANALYZER build report you can immediately visualize and access the target project's:
In addition, longitudinal builds of a project can be used as an annotated log/archive of the job's configuration changes. Since the configuration file of the analyzed project/job is archived, it can be used to compare or even revert back to a particular configuration version by simply re-deploying it to the project folder on the server.
An example build form is shown below. Note that if the selected PROJECT_NAME (project) has been analyzed previously, those builds are listed in the PROJECT_HISTORY list. The user can easily follow the links to review previous configuration analyses reports.
The build console output is organized using the Collapsing Console Sections Plugin. The console report displays a more detailed, textual view of the project configuration. Job component sections can be collapsed and expanded for easier inspection, and can be navigated to from a menu with section links.
The tabular build report uses the Summary Display Plugin to display each of the project configuration components in a separate tab. This is somewhat similar to the Jenkins v2.+ tabular UI used for job configuration, but in a much more compact form. Groovy code (whether embedded or managed in the scriptler catalog) and used in parameters, builders or publishers can be easily inspected and accessed from report links. The names and versions of applicable plugins used in parameters, builders and publishers, and build-wrappers are also reported.
And here is the parameter report from a project with several dynamic parameters
Each build generates a number of archived artifacts as shown in the example below
Archived artifacts are organized in folders some of which reflect the typical layout of a Jenkins installation. This makes it easier to package the job and as many of its dependencies for export to another server:
buildReportData
contains required data files for generating the tabbed build reportembeddedScripts
contains text files corresponding to embedded scripts (Groovy or command line script) in each of the project component. See naming convention for these scripts below.externalScripts
contains external Groovy scripts used in build and post build stepsjobs/JOB_NAME
contains a copy of the config.xml
file of the analyzed project.scriptler/scripts
contains the script dependencies of the project. These include scriptlets used for Active Choice and other parameters, and build and post build steps.The text scripts follow a naming convention TYPE_SerialID_[parameterName||null]_script.txt
where file names use a prefix indicating the component type where the script originated (parameter, builder, publisher etc.) and it's serial ID (the sequence number by which the component is ordered in the configuration file). If the component is a parameter, the parameter name is also included in the prefix.
So, an embedded script used in the 10th job parameter named BUILD_LABEL it is identified by a name like: parameter_10_BUILD_LABEL_script.txt
It is possible that jobs using configuration components and build steps beyond the ones we have tested may not parse correctly. We are using this utility primarily with freestyle projects that contain complex interacting parameters.
Pipeline, multi-configuration and multi-job projects have not been tested. The Cloudbees Folder Plugin is currently not supported. If your projects are organized using the Cloudbees Folder Plugin Jenkins-JobConfiguration Analyzer is not able to find the project configuration files. If you would like to extend the parser, it should be possible to modify the code in jobConfigParser to detect new parameters types and build steps (these are always reported in the console).