windows python virtualenv

1,230 views
Skip to first unread message

Dennis Marwood

unread,
Dec 30, 2016, 12:30:20 PM12/30/16
to Jenkins Users
Hi,

I would like to create and use a python virtualenv in my jenkins job. However, the "windows batch command" appears to just stop when I try to load the virtualenv. I don't see the "HERE" line in the steps below.


EXECUTE WINDOWS BATCH COMMAND

whoami
type nul > my_params.params
python -m venv env
env\Scripts\activate.bat
echo "HERE"


And here is some of the output:
C:\Jenkins\workspace\my_job>whoami
corp\my_user

C:\Jenkins\workspace\my_job>type nul  1>my_params.params 

C:\Jenkins\workspace\my_job>python -m venv env 

C:\Jenkins\workspace\my_job>env\Scripts\activate.bat
[EnvInject] - Injecting environment variables from a build step.
[EnvInject] - Injecting as environment variables the properties file path 'my_params.params'
[EnvInject] - Variables injected successfully.

Email was triggered for: Success
Sending email for trigger: Success
Request made to compress build log
Sending email to: m...@work.com
Finished: SUCCESS


Logging in as "my_user" and performing the steps manually in the workspace performs as expected.
The workspace contains all of the expected files and the virtualenv works if activated manually.
Windows Server 2008. Jenkins 2.19.4. Python 3.6
Is there something I need to do when activating a virtualenv for jenkins?


Richard Ginga

unread,
Jan 3, 2017, 11:00:45 AM1/3/17
to jenkins...@googlegroups.com
Dennis, when a batch file is called from a Windows Batch command build step, it must be called via "start xxx.bat" of Jenkins returns out of the shell as the conclusion of the batch file


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/434350ed-512d-4983-965b-a01a2e97cf64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dick Ginga
Build Engineer

Dennis Marwood

unread,
Jan 5, 2017, 2:01:27 PM1/5/17
to Jenkins Users
Thank you. I ended up using cmd to get this working.

type nul >my_params.params
python -m venv env
cmd /c "env\Scripts\activate.bat & echo Paths in use: & python -c "import sys; print('\n'.join(sys.path))" & pip install -r requirements.txt & python main.py & deactivate"


On Tuesday, 3 January 2017 08:00:45 UTC-8, Richard Ginga wrote:
Reply all
Reply to author
Forward
0 new messages