Running pylint against only changed lines/files with jenkins

做~自己de王妃 提交于 2021-01-02 05:09:09

问题


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!


回答1:


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




回答2:


There is a project lint-diffs that runs a linter on diff files only, and matches the results up to the diff output.

It should work for any linter and any vcs system, with appropriate configuration.



来源:https://stackoverflow.com/questions/39709619/running-pylint-against-only-changed-lines-files-with-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!