Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell Jenkins to use a particular virtualenv python

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

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

How I can ensure Jenkins is using the correct virtualenv?

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 
like image 262
Exploring Avatar asked Jan 13 '14 23:01

Exploring


People also ask

How do I specify Python version in Jenkins?

From the Jenkins console, browse to New Job. Enter a Job name and select Build multi-configuration project. Under Configuration Matrix, click Add Axis > Python. Select the Python version(s) to run this job against.

How do you select a Python interpreter in a virtual environment?

To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P). Note: If the Python extension doesn't find an interpreter, it issues a warning.

How can I tell which Virtualenv is active?

Note: Before installing a package, look for the name of your virtual environment within parentheses just before your command prompt. In the example above, the name of the environment is venv . If the name shows up, then you know that your virtual environment is active, and you can install your external dependencies.


1 Answers

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.

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

like image 116
Ivan Nevostruev Avatar answered Oct 11 '22 14:10

Ivan Nevostruev