I haven an Android Gradle build that is run on Jenkins.
Jenkins checks checkstyle warnings and errors and publishes the results. If there is a checkstyle error the build stops and is marked as failed. Jenkins also stops and does not publish the checkstyle report.
How can I let the build run through even with checkstyle errors?
The Checkstyle plugin performs quality checks on your project’s Java source files using Checkstyle and generates reports from these checks. Here we will see how to use checkstyle plugin in gradle based project.
Example 1. Using the Checkstyle plugin The plugin adds a number of tasks to the project that perform the quality checks. You can execute the checks by running gradle check. Note that Checkstyle will run with the same Java version used to run Gradle. The Checkstyle plugin adds the following tasks to the project:
We continue to add code analysis tooling to the Java build tasks with Checkstyle support for Gradle, and – in a few days – for Maven. Checkstyle is the analyzer of choice for enforcing a coding standard.
In our case, the config file is checkstyle.xml. The goal check mentioned in the execution section asks the plugin to run in the verify phase of the build and forces a build failure when a violation of coding standards occurs.
There is an even nicer and easier solution than that from Rene. Just add:
checkstyle {
ignoreFailures = true
}
to your build.gradle file.
The Checkstyle task can be configured to ignore failures:
checkstyleTask.ignoreFailures = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With