Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pylint with jenkins - complince that can't find xml file

I am trying to run pylint with jenkins with following command:

 pylint -f parseable -d I0011,R0801 "mypath\highLevel" | tee.exe pylint.out

The process looks run fine, pylint.out created with a lot of information inside but during pylint report creation I get following error:

13:38:27 ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception
13:38:27 java.io.FileNotFoundException: C:\Users\DMD\.jenkins\jobs\Diamond - Run Coverage\builds\2015-07-26_13-34-30\violations\file\A:\highLevel\Monitor\InitialBootAdapter.py.xml (The filename, directory name, or volume label syntax is incorrect)

It's creates very strange path:

C:\Users\DMD\.jenkins\jobs\Diamond - Run Coverage\builds\2015-07-26_13-34-30\violations\file\A:\highLevel\Monitor\InitialBootAdapter.py.xml

I don't really understand what happens. Why pylint is interested in file InitialBootAdapter.py? Why it's looks for file InitialBootAdapter.py.xml? Who should create it and why? I searched for this file over all the environment and didn't find. But I did'nt find any xml for my other py files? Maybe you have experience with pylint and can help? Thank you.

like image 934
Nana Avatar asked Dec 24 '22 16:12

Nana


2 Answers

I have experience with pylint in jenkins. And here is how I use it, hope it will help someone.

Step 1
Add a "Execute Shell" step and execute the pylint command to generate the pylint.out. Please note

/usr/local/bin/pylint -f parseable -d I0011,R0801 my-python-project-folder | tee pylint.out

Step 2
Make sure you have the Violation Report Plugin, after that , click Add post-build action-->Report Violation, put the pylint.out in the corresponding field. enter image description here

And after the successful run, the pylint report looks like this: enter image description here

like image 63
mainframer Avatar answered Jan 06 '23 22:01

mainframer


I fixed the problem, it took time and DevOps help but it worked and is described in my own blog (it's more my online notebook than blog) in very small details.

The most important point in this post is small utility

import fileinput, sys

if __name__ == "__main__":
    for line in fileinput.FileInput(sys.argv[1], inplace=True):
        if ".cs"  in line:
            line = line.replace("\\", "/")
        print line,

Here sys.argv[1] should be path to your violations.xml file. You have to move the path as a command line argument to the utility as path to your violations.xml file is dynamic and depends on build id.

like image 41
Nana Avatar answered Jan 06 '23 20:01

Nana