Reputation: 21
I have a Jenkins pipeline set up that, at this stage, lints a Dockerfile with hadolint and python files with Pylint.
While the Hadolint step is working, the Pylint step is throwing this error:
/var/lib/jenkins/workspace/readerXCL_blue@tmp/durable-7d7d2570/script.sh: line 2: pylint: command not found
script returned exit code 127
These are the relevant pipeline steps:
stage('Lint Dockerfile') {
steps {
sh 'hadolint Dockerfile'
}
}
stage('Lint Python') {
steps {
sh 'pylint --disable=C *.py'
}
}
I tried explicitly using bash (but bash seems to be default anyway) and setting up a venv to run pylint from, to no avail.
Both the pylint and hadolint commands are working used manually on the machine running Jenkins, which is an Ubuntu 18.04 EC2 VM.
Appreciate any help.
Upvotes: 1
Views: 688
Reputation: 21
The problem was in the Jenkins shell and the lack of virtualenv, apparently - even though Jenkins was configured to use bin/bash.
The way I solved it was:
steps {
sh 'bash ./lintpython.sh'
}
Inside lintpython.sh:
#!/bin/bash
python3 -m venv ~/.somevenv
source ~/.somevenv/bin/activate
pip install --upgrade pip &&\
pip install -r requirements.txt
pylint app.py
Upvotes: 1