1. Randy Syring
  2. jenkins-utils

Overview

HTTPS SSH

My Project

make sure you edit this file

Credits

Put things here.

Shebang Lines

If your project workspace path has spaces in it, the direct calls to a scripts with a shebang line at the top will fail. For example:

#!/var/lib/jenkins/jobs/SQLAlchemyBWC Install/workspace/.SQLAlchemyBWC-install-venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.0.2','console_scripts','pip'
__requires__ = 'pip==1.0.2'
import sys
from pkg_resources import load_entry_point

sys.exit(
   load_entry_point('pip==1.0.2', 'console_scripts', 'pip')()
)

If I use:

bh=BuildHelper('SQLAlchemyBWC', 'install')
bh.vecall('pip', 'install', 'SQLAlchemyBWC')

Then I will get the following:

calling: ('/var/lib/jenkins/jobs/SQLAlchemyBWC Install/workspace/.SQLAlchemyBWC-install-venv/bin/pip', 'install', 'SQLAlchemyBWC')
Traceback (most recent call last):
  File "scripts/jenkins-install.py", line 13, in <module>
    bh.vecall('pip', 'install', package)
  File "/home/rsyring/dev/python/jenkinsutils-src/jenkinsutils/__init__.py", line 78, in vecall
    self.oscall(\*args)
  File "/home/rsyring/dev/python/jenkinsutils-src/jenkinsutils/__init__.py", line 44, in oscall
    retcode = subprocess.call(args)
  File "/usr/lib/python2.6/subprocess.py", line 480, in call
    return Popen(\*popenargs, \**kwargs).wait()
  File "/usr/lib/python2.6/subprocess.py", line 633, in __init__
    errread, errwrite)
  File "/usr/lib/python2.6/subprocess.py", line 1139, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Because the pip file has a space in the shebang line, the kernel is trying to execute:

/var/lib/jenkins/jobs/SQLAlchemyBWC

In order to work around this, you have two options. First, name your projects so that there are no spaces in the workspace path. Second, for python scripts like the pip file above, you can call them using the python executable directly:

# note the call has a "py" in it, its not the same method as above
bh.vepycall('pip', 'install', 'SQLAlchemyBWC')

Which results in the following OS call:

calling: (
'/var/lib/jenkins/jobs/SQLAlchemyBWC Install/workspace/.SQLAlchemyBWC-install-venv/bin/python', '/var/lib/jenkins/jobs/SQLAlchemyBWC Install/workspace/.SQLAlchemyBWC-install-venv/bin/pip', 'install', 'SQLAlchemyBWC'

)

Since the shebang line is not used in this case, the problem is avoided.