Jenkins Code Analysis

Expect jenkins code anlysis buildout.

PyFlakes

  1. Install the warnings plugin:

    https://wiki.jenkins-ci.org/display/JENKINS/Warnings+Plugin
    
  2. 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);
buildout.jenkins.configure-warnings-pyflakes.png(options)
  1. Set up pyflakes warnings for job

Search for compiler warnings => search console =>

parser: pyflakes

_images/buildout.jenkins.warnings-plugin-pyflakes.png

ZPTLint

  1. Install the warnings plugin:

    https://wiki.jenkins-ci.org/display/JENKINS/Warnings+Plugin
    
  2. 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);
buildout.jenkins.configure-warnings-zptlint.png(options)
  1. Set up zptlint warnings for job

Search for compiler warnings => search console =>

parser: zptlint

images/buildout.jenkins.warnings-plugin-zptlint.png

Flake 8

  1. Install the warnings plugin:

    https://wiki.jenkins-ci.org/display/JENKINS/Warnings+Plugin
    
  2. 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);;
buildout.jenkins.configure-warnings-flakes8.png(options)
  1. Set up flakes8 warnings for job

Search for compiler warnings => search console =>

parser: flakes8

images/buildout.jenkins.warnings-plugin-flakes8.png

UTF-8 headers

  1. Install the warnings plugin:

    https://wiki.jenkins-ci.org/display/JENKINS/Warnings+Plugin
    
  2. 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);
buildout.jenkins.configure-warnings-utf-8.png(options)
  1. Set up utf-8 warnings for job

Search for compiler warnings => search console =>

parser: utf-8 headers

images/buildout.jenkins.warnings-plugin-utf-8.png

XMLLint

  1. Install xmllint on the Jenkins server:

    $ sudo apt-get install libxml2-utils
    
  2. ...

Open Tasks

  1. Install the task scanner plugin:

    https://wiki.jenkins-ci.org/display/JENKINS/Task+Scanner+Plugin
    
  2. 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

_images/buildout.jenkins.open-tasks.png