我尝试配置新的jekins服务器和作业。我有Jenkins ver。 2.19.4。我对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 USER@IP
这应该将我构建的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 :(得分:0)
我的建议是不要在Jenkin的任务中进行此安装。首先在构建场计算机中准备运行时环境。然后编写Jenkins任务脚本来完成剩下的工作。
BTW,virtualenv与Jenkins的合作非常好,因为它创建了一个新的环境,并且可能有一些问题需要继承Jenkins所需的env变量。