2015-07-20 41 views
0

我正在尝试设置一个jenkins作业来运行我的lint.py文件。我运行詹金斯命令是:与jenkins运行pylinter

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工作,因为包安装somwhere。我曾尝试将PYTHONPATH="/var/lib/jenkins/.local/lib/python2.7/site-packages" python lint.py添加到命令中,但我得到了相同的结果。

有谁知道我能做些什么来使lint.py运行?谢谢。

+0

你可以尝试在详细模式下为用户詹金斯(须藤-u詹金斯蟒蛇-v)运行Python和看到它看起来为pylint?如果它找到它,你可以弄清楚如何操作你的pythonpath来使它正常工作。 –

回答

0

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

sudo apt-get install pylint 

如果这不起作用,验证您使用的Python设置是您期望的设置。

which python 
which pip 
pip freeze 

或者以下的插件可能会为你工作:

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

+0

嗨@Luke,我很困惑你的答案。在上面输出的第一行中,机器清楚地认为pylint安装在某处。另外,这些作业在多台计算机上运行,​​因此,使用'sudo apt-get install'安装它一次就不会起作用。 –

+0

最初的pip安装似乎认为它已安装。但是,如果没有验证python和pip位置,您可能会在机器上安装多个python。 –