JUnit Linting for Clojure with Eastwood

10 May 2015, Rhodri Pugh

We use Clojure for most of our service layer, and run all our CI stuff through the venerable Jenkins server. I recently wanted to add support for the Eastwood linting tool to our standard Leiningen job on Jenkins (which previously just ran unit tests) to give us some extra feedback amd possibly catch errors or suggest improvements automatically.

Jenkins Publishers

Jenkins comes with a number of built-in post-build publishers. The job of these publishers is to take artifacts produced by the build, ingest and process them, and produce formatted reporting of their contents. The status of the build can also be affected by these publishers should they find information that means things like tests failed, etc…

You’re then able, via the Jenkins UI, to browse this information.


Eastwood is a library that does linting of Clojure source code, reporting errors like namespaces not matching files, local shadowing of vars, and incorrect function call aritities. It comes with a Leiningen plugin that allows easy execution from the shell:

$> cd my-project
$> lein eastwood

Or with parameters specified as a map

$> lein eastwood '{:namespaces [my-project.web my-project.util]}'

This will then report to stdout any errors that it finds. It’s also easily used as a library if you’d like to call it directly from your IDE of choice…

(require '[eastwood.lint :refer [lint]])

(lint {:source-paths ["src"]}) ; returns a map of errors

JUnit Integration

When calling Eastwood using the Leiningen plugin it does correctly return a non-zero exit code when errors are found, so it’s quite simple to run this under Jenkins and have it fail a build. The error messages will then be visible by looking at the console output from the build. It’d be nice to have the integration mentioned previously with the data being parsed and available from the UI though…

At the moment Eastwood doesn’t provide the facility for formatting structured data as the JUnit format requires, so we’ve added a very small wrapper to do this. It’s implemented as another Leiningen plugin…


Usage is the same as you would with Eastwood itself…

$> cd my-project
$> lein eastwood-junit

This then writes the JUnit XML to stdout, so you can redirect it to a file and have Jenkins suck it in with a post-build publisher.

$> lein eastwood-junit > eastwood-junit.xml


It’s not really a lot of bother to read these errors via the Jenkins build output, but it’s nice to have everything available in the same format (and it also allows recording metrics about code quality over time). Maybe Eastwood will add this kind of feature in the future (it does still describe itself as alpha quality), but even if it doesn’t it provides a good API for extending it via other plugins, and maybe this is the best place for it anyway.