ignore certain files from pylint scan in jenkins

255 views Asked by At

am new to working on jenkins. am trying to integrate pylint with jenkins build.In my jenkins file am saying it to scan all the files with .py extension and deploy only if jenkins build score is greater than 9/10. I have a situation where I need to tell pylint to explicitly ignore certain files. I went through pylint documentation and found that we can use pylint-ignore or add files to ignore section in pylint.cfg file

my jenkins scan code looks like below

stage('Code Scan - Python') {
            steps{
                script {
                    sh '''
                    eval $(pylint --version --rcfile=pylint.cfg $(find . -type f -name "*.py") --output-format=parseable -r y > pylint.log)
                    pip install pylint-ignore 
                    pylint-ignore --rcfile=pylint.cfg pandas,numpy,psycopg2,node_modules,numpy-1.20.1.dist-info,pytz,six-1.15.0.dist-info,six.py,numpy.libs,dateutil,pydash,python_dateutil-2.8.1.dist-info
                    cat pylint.log
                    pylint-fail-under --fail_under 9.0 pylint-ignore --rcfile=pylint.cfg pandas,numpy,psycopg2,node_modules,numpy-1.20.1.dist-info,pytz,six-1.15.0.dist-info,six.py,numpy.libs,dateutil,pydash,python_dateutil-2.8.1.dist-info --rcfile=pylint.cfg --output-format=parseable -r y
                    '''
                }
            }
        }

I get this error

Invalid path, does not exist: pylint-ignore.md

But If i execute

pylint --rcfile=omni-eventing-pub-sub-tmp/pylint.cfg  omni-eventing-pub-sub-tmp

from my command line, it ignore all the files that i specified in my pylint.cfg file with .py extension like

ignore=pandas,numpy,psycopg2

and gives me a score. I am trying to do the same with jenkins and having a hard time

1

There are 1 answers

0
ashakshan On

I had to specify -path and pass the directory in which I have my .py files

eval $(pylint --rcfile=pylint.cfg $(find . -type f -path '*/src/*.py')  --output-format=parseable -r y > pylint.log)