{jenkins-plugin-info:pluginId=jenkinslint}

Detects whether your Jenkins configuration follows those best practices 

This plugin has mainly two goals:

  • To make it easier to detect issues in your Jenkins configuration that will cause Jenkins to blow up when you attempt to run those jobs.
  • To encourage discussion within the Jenkins community on the more subjective stuff. Having a set of checks to base discussion on helps drive out what we as a community think is good style.
   

Summary

Jenkins is an awesome Automation System, and there are a bunch of people using it in different ways, for example: developers, testers, automation, build engineers, release engineers, scrum master, product owner and so on. Unfortunately, as the number of jobs grows, maintaining them becomes tedious, and the paradigm of using a predefined set of best practices falls apart.

The Jenkins Lint plugin attempts to solve this problem by allowing jobs to be evaluated with some predefined best practices. The goal is for your team to be able to define those best practices to be related to their project.

Manually reviewing those jobs wouldn't be too hard, but doing the same thing all over again for every new job or for a hundred other projects is where it gets difficult and tedious. This provides a much more powerful way of analyzing them.

Usage

You can find it under <jenkins_url>/jenkinslint or reach it via links in the sidepanel of the main page. You don't need to do anything else, just click on the Jenkins Lint link and those Lint checkers will be shown.



 

Features

List of available Job checks:

List of available Slave checks:

Planned upcoming features

Controlling checks:

You can ignore a particular check  in a specific job, by adding a trailing lint:ignore:<check name> comment to the job description.

You can ignore a check globally, by deselecting it in the system configuration: "Manage Jenkins" / "Configure System" in the "Advanced" section below "Jenkins Lint".

Disabling the healthy floating box in the Job Summary Page

You can disable the healthy floating box in the Job Summary Page, by unchecking "Enable JobAction" in the system configuration 

Features controlled by system properties

Based on the Features controlled by system properties, you can disable the healthy floating box in the Job Summary Page

Property

Default

Version

Notes

org.jenkins.ci.plugins.jenkinslint.JobLintAction.disabled

false

0.9.0

Deprecated since 0.10.0. Removed since 0.12.0.


By default you will see the below view:

 

If you disabled then:

Global settings

You can easily disable/enable Checkers and customise them from the Global Settings <jenkins_url>/configure section "Jenkins Lint"  

 

Enable/Disable with Groovy script

You can also configure your lint checkers using the Script console, from version 0.10.0 onwards!

import org.jenkins.ci.plugins.jenkinslint.JenkinsLintGlobalConfiguration
import jenkins.model.GlobalConfiguration

// Disable Globally
JenkinsLintGlobalConfiguration.all().get(JenkinsLintGlobalConfiguration.class).setGlobalEnabled(false)

// Disable JobAction
JenkinsLintGlobalConfiguration.all().get(JenkinsLintGlobalConfiguration.class).setJobActionEnabled(false)

// Disable Lint
JenkinsLintGlobalConfiguration.all().get(JenkinsLintGlobalConfiguration.class).setCleanupWorkspaceCheckerEnabled(false)
 
// More properties in the JenkinsLintGlobalConfiguration class: https://github.com/jenkinsci/jenkinslint-plugin/blob/a97f3e17b14d7410164bb4bea50ba5968a3a97b8/src/main/java/org/jenkins/ci/plugins/jenkinslint/JenkinsLintGlobalConfiguration.java#L18-L45

API

You can retrieve jenkins lint defects by requesting the following URLs :


And also you can retrieve lint defects per job/agents:

Workaround

 

There is already a known issue in the initial version 0.1.0Workspace Cleanup Plugin is a required dependency otherwise JenkinsLint will fail when analyzing those Jobs

Jul 13, 2015 10:21:06 PM hudson.ExpressionFactory2$JexlExpression evaluate
WARNING: Caught exception evaluating: it.data in /jenkinslint/. Reason: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)

.... Giant Stacktrack ....

        at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: hudson/plugins/ws_cleanup/WsCleanup$DescriptorImpl
        at org.jenkins.ci.plugins.jenkinslint.check.CleanupWorkspaceChecker.executeCheck(CleanupWorkspaceChecker.java:22
)
        at org.jenkins.ci.plugins.jenkinslint.JenkinsLintAction.getData(JenkinsLintAction.java:60)
        ... 112 more

There are two workarounds:

  1. Installing  Workspace Cleanup Plugin 
  2. Upgrading the JenkinsLint version

Requirements

Jenkins

Jenkins version:

It might work with previous versions.

NOTE: Jenkins version is required when testing those checkers using the mvn test command. This plugin uses java reflection to get rid of those plugins/jenkins version dependencies although it's required in the test phase when developing it to verify/test those checkers.

Open Issues

Version history

Planning 

(plus) Check: Cyclomatic complexity check (issue #42269)

Version 0.14.0 (August 29, 2017)

Version 0.13.0 (August 24, 2017)

Version 0.12.0 (August 15, 2017) 

Version 0.11.0 (August 10, 2017)

Version 0.10.1  (August 1, 2017)

Version 0.10.0  (August 1, 2017)

Version 0.9.0 (July 27, 2017)

Version 0.8.0 (Mar 7, 2017)

Version 0.7.0 (Feb 26, 2017)

Version 0.6.0 (Feb 12, 2017)

Version 0.5.0 (Oct 1, 2015)

Version 0.4.0 (Aug 27, 2015)

Version 0.3.0 (Jul 29, 2015)

Version 0.2.0 (Jul 21, 2015)

Version 0.1.2 (Jul 15, 2015)

Version 0.1.1 (Jul 14, 2015)

Version 0.1.0 (Jul 12, 2015)