如何告诉 Jenkins 使用特定的 virtualenv python [英] How to tell Jenkins to use a particular virtualenv python

查看:66
本文介绍了如何告诉 Jenkins 使用特定的 virtualenv python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个 virtualenv 来运行我的 python 脚本.

I have already created a virtualenv for running my python script.

现在当我将这个 python 脚本与 Jenkins 集成时,我发现在执行时 Jenkins 使用了错误的 python 环境.

Now when I integrate this python scrip with Jenkins, I have found at the time execution Jenkins is using wrong python environment.

我如何确保 Jenkins 使用正确的 virtualenv?

How I can ensure Jenkins is using the correct virtualenv?

例如,对于我的情况,我想使用 virtualenv 测试.我如何使用这个预先准备好的 virtualenv 来运行我的 python 脚本.

As an example, for my case I want to use virtualenv test. How I can use this pre-prepared virtualenv to run my python script.

source test/bin/activate 

推荐答案

您应该安装 Python 插件之一.我用过 ShiningPanda.然后,您将能够在管理 Jenkins > 配置系统 > Python > Python 安装中创建单独的虚拟环境配置.在作业配置中会有 Python Builder 步骤,您可以在其中选择 Python 环境.

You should install one of python plugins. I've used ShiningPanda. Then you'll be able to create separate virtual environment configurations in Manage Jenkins > Configure System > Python > Python installation. In job configuration there will be Python Builder step, where you can select python environment.

只要确保您没有从现有的 Python 虚拟环境中启动 Jenkins 服务.

Just make sure you're not starting Jenkins service from within existing python virtual environment.

这篇关于如何告诉 Jenkins 使用特定的 virtualenv python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆