I have installed Jenkins on ubuntu 15.10. In a shell build step I am trying to create a Python virtual environment and activate it: enter image description here

But I get the following error when I run the job:

/tmp/hudson4515625893361069094.sh: 9: /tmp/hudson4515625893361069094.sh: source: not found

More from the log:

[django-demo] $ /bin/sh -xe /tmp/hudson4515625893361069094.sh
+ virtualenv --no-site-packages virtual_django
New python executable in virtual_django/bin/python2
Also creating executable in virtual_django/bin/python
Installing setuptools, pip...done.
Running virtualenv with interpreter /usr/bin/python2
+ cd virtual_django/bin
+ pwd
+ dir
activate      activate.fish easy_install      pip   pip2.7  python2
activate.csh  activate_this.py  easy_install-2.7  pip2  python  python2.7
+ source activate
/tmp/hudson4515625893361069094.sh: 9: /tmp/hudson4515625893361069094.sh: source: not found
Build step 'Execute shell' marked build as failure

So the virtual environment was created successfully but it cannot be activated because the source command cannot be found.

I did verify that I can indeed run the source activate command from a terminal on the machine as the jenkins user in the corresponding workspace:

jenkins@vmi63860 ~/workspace/django-demo/virtual_django/bin ((HEAD detached at 290c6a4)) $ source activate
(virtual_django)jenkins@vmi63860 ~/workspace/django-demo/virtual_django/bin ((HEAD detached at 290c6a4)) $ exit

So why does it fail when I run it under the Jenkins job?

1 Answer 1


Found a similar post here:


The solution is to add:


in the first line of the script step:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.