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.
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.
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
List of available Job checks:
- Artifact Publisher check
- BFA check
- Built Timeout check
- CleanUp Workspace check
- Git Ref repo check
- Git Ref Submodule repo check
- Git Shallow clone check
- Gradle Wrapper check
- Groovy system exit check
- Hard-coded Script check
- Javadoc Publisher check
- Job Assigned Label check
- Master Assigned Label check
- Job Description check
- Job Log Rotator check
- Job Name check
- Maven Job Type check
- Multibranch Job Type check
- Null SCM check
- Polling SCM Trigger check
- TimerTrigger Hash check
List of available Slave checks:
- Slave description check
- Slave label check
- Slave version check
- Windows slave launch check
- Configure Checks (change severity)
- Load checks dynamically via Jenkins.
- Load checks dynamically via Reflection.
- Define some kind of programmatically scripts.
- Check: Cyclomatic complexity check
- Support Declarative pipeline and shared Libraries
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
Based on the Features controlled by system properties, you can disable the healthy floating box in the Job Summary Page
By default you will see the below view:
If you disabled then:
You can easily disable/enable Checkers and customise them from the Global Settings <jenkins_url>/configure section "Jenkins Lint"
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
You can retrieve jenkins lint defects by requesting the following URLs :
And also you can retrieve lint defects per job/agents:
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:
- Installing Workspace Cleanup Plugin
- Upgrading the JenkinsLint version
- 1.607 or newer if Jenkins pipelines are installed
- 1.580 or newer is required if jenkins pipelines are not installed
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.
Check: Cyclomatic complexity check (issue #42269)
- Enable/Disable whether to analyse disabled jobs from Global Settings (issue #46395)
- Show graphs. (issue #46350)
- Fixed NPE when using MultijobProjects (issue #46424)
- Fixed ClassCastException when using a misconfigured restrict where to run field (issue #46383)
- Check: Detect ignored groovy sandbox in Projects. (issue #46177 )
- Check: Detect ignored groovy sandbox in Pipelines. (issue #46162)
- Customise HardcodedScript lint to enable/disable comments as lines. (issue #46146)
- Fully support of Pipeline linting. (issue #46162)
- Search box. (issue #42359)
- Bumped minimal Jenkins Core version to 1.607 (issue #46162)
- Remove: Deprecated System Property (Features controlled by system properties) . (issue #46164)
- Fixed Column Ordering based on Check Status and Job/Slave Name (issue #46033)
- Fixed Linting with multi-configuration projects. (issue #46176)
- Check: Groovy system exit check in Input Parameters (issue #45961)
- Check: Groovy system exit check in Publishers (issue #45960)
- Check: Run Timeout Check in Build Steps (issue #45938)
- Fixed Hardcoded Script check with empty lines (issue #46035)
- Fixed Column Ordering based on Check Status and Job Name (issue #46033)
Fixed false positive with Timer Trigger Checker (issue #45879)
Fixed sortable columns (issue #45880)
Check: BFA Check (issue #42268)
Check: Git Ref Submodule Check (issue #41528)
Enable/Disable Checks globally/individually from Global Settings (issue #45882)
Hardcoded Script Threshold value is now part of the Global Settings (issue #45882)
- JobAction View (Controlled by System Property) (PR #17)
- AgentAction View (PR #17)
- RestAPI for the JobAction and AgentAction
- Jenkinsfile integration with ci.jenkins.io (PR #18)
- Fixed Jelly and XSS prevention
- Bumped minimal Jenkins Core version to 1.580
- RestAPI. (issue #41449)
- TimerTrigger 'Hash' check supporting @ (issue #42337)
- Removed dependent plugins. (issue #42383)
- Maven and Matrix projects weren't supported when linting some defects (issue #42310)
- Check: TimerTrigger 'Hash' check (issue #42267)
- i18 support
- Check: Git local ref cache repos check (issue #41528)
- Check: Groovy system exit check (issue #38617)
- Updated pom file (infra #588)
- Check: Build Timeout check (issue #30725)
- Support Jenkins lint check for Jenkins Slaves (issue #30161)
- Check: Gradle Wrapper check (issue #29486)
- Health Icons plus percentage (issue #29466)
- Refactor: remove optional dependencies (issue #29545) (issue #29544) (issue #29546)
- Some builders cannot be cast to hudson.tasks.CommandInterpreter (issue #29427)
- HardcodedScript Check supports MatrixProjects (issue #29444)
- Create unit test suite for UI
- Project dependency with ws-cleanup plugin (issue #29418)
- Check: Hardcoded Script check