Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running pylint against only changed lines/files with jenkins

At this time, I am using the violations plugin with Jenkins to generate a report of PEP8 violations. Since I am only beginning to use this check, there are an insane number of violations. So I'd like to start with only checking what changed in a pull request.

When a pull request is opened, I use the github pull request builder in order to test the pull request, and I'd also like to check the styling using pylint (or equivalent) as well.

I use this command in order to generate my current pylint report for jenkins

pylint -f parseable ‘/var/lib/ci_server/workspace/pylint_check’ | tee pylint.out

The above command will scan the entire project rather than just changes in the pull request.

I've also tried using this:

git diff-index —name-only HEAD | grep .py | xargs pylint -f pylint -f parseable | tee pylint.out

^ This command runs the build, but yields 0 violations on my pull request... It looks like that my pull requests show up in a detached HEAD sort of state (I assume git diff no longer works in this context?)

The overall goal here is to scan for style violations within changes in a pull request using Jenkins... I've been pulling my hair over this for a couple days now. Any help would be super great, cheers!

like image 391
nbb Avatar asked Sep 26 '16 18:09

nbb


1 Answers

Check out git-lint. It seems to do what you're looking to accomplish.

like image 85
Evan Grim Avatar answered Oct 14 '22 05:10

Evan Grim