Home > Mobile >  Jenkins in Windows Stops after Activating Python VENV
Jenkins in Windows Stops after Activating Python VENV

Time:11-23

When running a build in Windows, Jenkins does not get past activation of a Python virtual environment.

I have setup Jenkins server in Windows 10 to run unit tests in Python. I created a "Freestyle project". In "Build", I selected "Execute Windows batch command" and entered these commands:

echo 'BEFORE ACTIVATION'
C:\Development\venvs\venv366-001\Scripts\activate.bat
echo 'AFTER ACTIVATION'

I start the build by clicking "Build Now". The build is successful, and console output displays the following:

C:\ProgramData\Jenkins\.jenkins\workspace\DemoCalculator>echo 'BEFORE ACTIVATION' 
'BEFORE ACTIVATION'

C:\ProgramData\Jenkins\.jenkins\workspace\DemoCalculator>C:\Development\venvs\venv366-001\Scripts\activate.bat
Finished: SUCCESS

Notice that the console does not indicate AFTER ACTIVATION. In practice, I would put non-trivial commands after activation. This example only shows that nothing after activation is run.

How can I get later commands to run?

CodePudding user response:

See SS64 > CMD > CALL:

The Microsoft help for the CALL command states: "Calls one batch program from another without stopping the parent batch program"

So, call activate.bat by:

call C:\Development\venvs\venv366-001\Scripts\activate.bat 
  • Related