2016-12-24 78 views
0

我試圖配置新的jekins服務器和作業。我有詹金斯ver。 2.19.4。我有一些的virtualenv問題,我不知道該怎麼辦詹金斯看不到命令​​virtualenv

我的腳本是什麼:

#!/bin/bash 
pip install virtualenv 

PYENV_HOME=$WORKSPACE/.pyenv/ 

# Delete previously built virtualenv 
if [ -d $PYENV_HOME ]; then 
    rm -rf $PYENV_HOME 
fi 

# Create virtualenv and install necessary packages 
virtualenv --no-site-packages $PYENV_HOME 
. $PYENV_HOME/bin/activate 

pip install paramiko 
python ./deploy.py [email protected] 

這應該部署我建造UI到服務器上,但我需要安裝paramiko LIB但jekins看不到一個virutalenv也有問題,安裝的paramiko本身

輸出日誌:

Collecting virtualenv 
    Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB) 
Installing collected packages: virtualenv 
Successfully installed virtualenv-15.1.0 
You are using pip version 8.1.1, however version 9.0.1 is available. 
You should consider upgrading via the 'pip install --upgrade pip' command. 
/tmp/hudson5253487294321466077.sh: line 12: virtualenv: command not found 
/tmp/hudson5253487294321466077.sh: line 13: /var/lib/jenkins/workspace/UI3/.pyenv//bin/activate: No such file or directory 
Collecting paramiko 
    Using cached paramiko-2.1.1-py2.py3-none-any.whl 
Collecting pyasn1>=0.1.7 (from paramiko) 
    Using cached pyasn1-0.1.9-py2.py3-none-any.whl 
Collecting cryptography>=1.1 (from paramiko) 
. 
. 
. 
failed on install crypthography 
. 
. 
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-zukA89/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-pprj1d-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-zukA89/cryptography/ 
You are using pip version 8.1.1, however version 9.0.1 is available. 
You should consider upgrading via the 'pip install --upgrade pip' command. 
Traceback (most recent call last): 
    File "./deploy.py", line 7, in <module> 
    import paramiko 
ImportError: No module named paramiko 
Build step 'Execute shell' marked build as failure 
Finished: FAILURE 

回答

0

我的建議是不要做這種安裝在詹金的任務。首先在您的構建服務器場中準備運行時環境。然後編寫Jenkins任務腳本來完成剩下的工作。

順便說一句,virtualenv不能很好地與Jenkins一起工作,因爲它創建了一個新的環境,並且可能會有一些問題來繼承Jenkins需要的env變量。

+0

有了這種類型的工作流程工作謝謝 – Sebastian