Embed SLOCCount into Jenkins jobs


Install SLOCCount and cloc on system.

$ aptitude install sloccount cloc

Search and install the “SLOCCount Plugin”.

jenkins sloccount plugin
Search SLOCCount Plugin


Now search your job and start configuration and insert the command “Build > Execute Shell”.

sloccount --duplicates --wide --details ${WORKSPACE}/<file|folder> > sloccount_report.sc

As last step add the Post-Build-Action – “View SLOCCount results” and insert the generated report “sloccount_report.sc”.

sloccount result path
Configure Post-Build-Action

The plugin just show the number of lines per file, file type and folder. No estimated project value or other informations! This information you can see direct on generated report. After running the build, your screen should look similar like this:

sloccount report
SLOCCount report