使用jenkins运行一个pylinter

时间:2015-07-20 19:45:08

标签: python pip

我正在尝试设置jenkins作业来运行我的lint.py文件。我正在运行的jenkins命令是:

 pip install -r requirements.txt 
 python lint.py

我看到的输出是:

Requirement already satisfied (use --upgrade to upgrade): pylint in /var/lib/jenkins/.local/lib/python2.7/site-packages (from -r requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): sqlalchemy in /var/lib/jenkins/.local/lib/python2.7/site-packages (from -r requirements.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): pandas in /var/lib/jenkins/.local/lib/python2.7/site-packages (from -r requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /usr/local/lib/python2.7/dist-packages (from pandas->-r requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): pytz>=2011k in /var/lib/jenkins/.local/lib/python2.7/site-packages (from pandas->-r requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.0 in /var/lib/jenkins/.local/lib/python2.7/site-packages (from pandas->-r requirements.txt (line 3))
Cleaning up...
+ python lint.py
sh: 1: pylint: not found
sh: 1: pylint: not found
sh: 1: pylint: not found
sh: 1: pylint: not found
sh: 1: pylint: not found
sh: 1: pylint: not found
sh: 1: pylint: not found
sh: 1: pylint: not found
sh: 1: pylint: not found
sh: 1: pylint: not found
sh: 1: pylint: not found
sh: 1: pylint: not found
['lint.py']
no directory specified, defaulting to current working directory

此时作业失败。

所以:软件包已经安装,但在lint.py运行时却找不到它。

当我手动执行此操作时,sudo pip install pylintlint.py可以愉快地运行,但这不是jenkins作业的选项。此外,我相信这应该能够在没有sudo的情况下工作,因为已安装在其中。我已经尝试将PYTHONPATH="/var/lib/jenkins/.local/lib/python2.7/site-packages" python lint.py添加到命令中,但我得到了相同的结果。

有谁知道我可以做些什么来启用lint.py?谢谢。

1 个答案:

答案 0 :(得分:0)

看起来没有安装pylint。你在运行什么操作系统?如果是Debian或Ubuntu:

sudo apt-get install pylint

如果这不起作用,则验证您正在使用的python设置是您期望的设置。

which python
which pip
pip freeze

或者,以下插件可能适合您:

https://wiki.jenkins-ci.org/display/JENKINS/Violations