5

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
/var/lib/jenkins/workspace/django-demo/virtual_django/bin
+ 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?

6

Found a similar post here:

https://stackoverflow.com/questions/670191/getting-a-source-not-found-error-when-using-source-in-a-bash-script

The solution is to add:

#!/bin/bash

in the first line of the script step:

enter image description here

| improve this answer | |

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.