2016-12-24 83 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