Running Analysis Commands¶
Analysis commands run in our regular build environment and are just regular commands that
produce one of our supported output formats like
checkstyle. A command can either
be some script you have written or a Scrutinizer analysis or another open-source analysis tool.
For some analysis tools (Scrutinizer's own analysis and some open-source tools), we provide lightweight shell script wrappers that wrap the real analysis command and automatically set-up its output format and result file options.
If your analysis tool is not among these analysis tools, it is still
fully supported on Scrutinizer except that you need to manually define the
options for the command below.
The analysis command is run just like any other command except that a new key
added to your command hash. Under that
analysis key, we define where the platform should
look for the output of the tool and what format the output has. Once, the command has been run,
the platform will automatically pick up the output at this location and then process it further.
build: nodes: analysis: tests: override: - command: ./run-my-analysis --result-file=output.xml analysis: file: output.xml # Where the output is written format: 'general-checkstyle' # The format that this file has. Currently # the common checkstyle format is supported.
If a tool pipes output to STDOUT, you can redirect the output to file like this:
build: nodes: analysis: tests: override: - command: ./run-my-analysis > analysis-output.xml analysis: file: analysis-output.xml format: 'general-checkstyle'
The output of the command is expected to be a
checkstyle XML file. The structure should roughly look
<?xml version="1.0" encoding="UTF-8"?> <checkstyle version="1.0.0"> <file name="/path/to/code/myfile.php"> <error line="2" message="msg1" source="Ruleset.RuleName"/> <error line="20" message="msg2" source="Generic.Constant"/> <error line="47" message="msg3" source="ScopeIndent"/> <error line="47" message="msg4" source="Format.MultipleAlignment"/> <error line="51" message="msg5" source="Comment.FunctionComment"/> </file> </checkstyle>