2015-07-20 75 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。 –