Configuring SBT JSLint With TeamCity Build
In this post I will shortly describe configuration process of JSLint SBT plugin and then TeamCity build config that reacts on errors/warnings raised by this plugin.
After some research it appeared that JSLint is for JS the same as FindBugs for Java so we decided to try it out in our project. Luckily there is a JSLint SBT plugin so we weren’t forced to carve our own solution.
According to the documentation to configure plugin we have to perform two following steps:
- Add plugin declaration to Plugins.scala file
1 2 3 4 5 6 7 8
- Include plugin settings in Build.scala:
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
When you analyse report.xml you might be overwhelmed by the number of warnings raised by the plugin. Some of them are quite useful, but some might be ignored or, even better, disabled by custom flags. In our project we use something like:
added to lintCustomSettings. For more flags and their descriptions please visit plugin documentation.
Team City config
Now, as we have our plugin running and generating report.xml, we could configure TeamCity build to react on JS errors and warnings.
Simply go to Edit Configuration Settings of your build and then choose “Build Step: Command Line”:
And in the section Additional Build Features click “Add build feature”, choose “XML report processing”, then “JSLint” and specify path to the report.xml file. Personally I also check “Verbose output” to see more details in the build log.
After saving we can go next build step named “Build failure conditions” and define two new rules there so we end up with something similar to screen presented below:
Reference commits from my current project: