Jenkins Code Analysis¶
Expect jenkins code anlysis buildout.
PyFlakes¶
Install the warnings plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Warnings+Plugin
Set up a compiler warnings in jenkins configure.
Name:
pyflakes
Regular Expression:
^(.*):([0-9]*):(.*)$
Mapping Script:
import hudson.plugins.warnings.parser.Warning
import hudson.plugins.analysis.util.model.Priority
String fileName = matcher.group(1)
String category = "PyFlakes Error"
String lineNumber = matcher.group(2)
String message = matcher.group(3)
return new Warning(fileName, Integer.parseInt(lineNumber), category, "PyFlakes Parser", message, Priority.NORMAL);
- Set up pyflakes warnings for job
Search for compiler warnings => search console =>
parser: pyflakes
ZPTLint¶
Install the warnings plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Warnings+Plugin
Set up a compiler warnings in jenkins configure.
Name:
zptlint
Regular Expression:
^.*in:s(S*)s*(?:<classs’)?(S*)(?:’>)?:s(.*)s*,.*lines*([0-9]*).*$
Mapping Script:
import hudson.plugins.warnings.parser.Warning
import hudson.plugins.analysis.util.model.Priority
String fileName = matcher.group(1)
String category = matcher.group(2)
String lineNumber = matcher.group(4)
String message = matcher.group(3)
return new Warning(fileName, Integer.parseInt(lineNumber), category, "ZPTLint Parser", message, Priority.HIGH);
- Set up zptlint warnings for job
Search for compiler warnings => search console =>
parser: zptlint
Flake 8¶
Install the warnings plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Warnings+Plugin
Set up a compiler warnings in jenkins configure.
Name:
Flake8
Regular Expression:
^(.*):([0-9]*):([0-9]*):(.E[0-9]*)(.*)$
Mapping Script:
import hudson.plugins.warnings.parser.Warning
import hudson.plugins.analysis.util.model.Priority
String fileName = matcher.group(1)
String lineNumber = matcher.group(2)
String message = matcher.group(5)
String category = matcher.group(4)
return new Warning(fileName, Integer.parseInt(lineNumber), category, "PyFlakes Parser", message, Priority.NORMAL);;
- Set up flakes8 warnings for job
Search for compiler warnings => search console =>
parser: flakes8
UTF-8 headers¶
Install the warnings plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Warnings+Plugin
Set up a compiler warnings in jenkins configure.
Name:
utf-8 headers
Regular Expression:
(.*)
Mapping Script:
import hudson.plugins.warnings.parser.Warning
import hudson.plugins.analysis.util.model.Priority
String fileName = matcher.group(1)
return new Warning(fileName, 1, "utf-8", "encoding", "Missing # -*- coding: utf-8 -*- in python file.", Priority.LOW);
- Set up utf-8 warnings for job
Search for compiler warnings => search console =>
parser: utf-8 headers
XMLLint¶
Install xmllint on the Jenkins server:
$ sudo apt-get install libxml2-utils
...
Open Tasks¶
Install the task scanner plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Task+Scanner+Plugin
Configure your Jenkins job:
Go to section “Post-build Actions”. Check the “Scan workspace for open tasks” checkbox and fill out the settings:
Files to scan: packages/**/*
Files to exclude: packages//*.png, packages//.gif, packages/*/.jpg, packages/*/.zip, packages/*/.ppt, packages/*/.jar, packages/*/.stx, packages/*/CHANGES.txt, packages//HISTORY.txt, packages//INSTALL.txt, packages//*.rst, packages//CHANGELOG.txt, packages/**/ChangeLog
Tasks tags: Normal priority: XXX, BBB, TODO