jenkins-job-builder setup on mac

jenkins-job-builder setup on mac

During my work day I use jenkins-jobs a lot since we have a lot of jenkins jobs. Running this tool on Centos, works like a charm. Tried to setup on my MAC and I failed to run it. Got the following errors:

knesenko@knesenko-mbp:~$ jenkins-jobs 
Traceback (most recent call last):
  File "/usr/local/bin/jenkins-jobs", line 6, in 
    from jenkins_jobs.cmd import main
  File "/Library/Python/2.7/site-packages/jenkins_jobs/cmd.py", line 27, in 
    from jenkins_jobs.builder import Builder
  File "/Library/Python/2.7/site-packages/jenkins_jobs/builder.py", line 25, in 
    import jenkins
  File "/Library/Python/2.7/site-packages/jenkins/__init__.py", line 54, in 
    from six.moves.http_client import BadStatusLine
ImportError: No module named http_client

The issue is MAC trying to use the old six version:

knesenko@knesenko-mbp:~$ ipython
Python 2.7.10 (default, Jul 14 2015, 19:46:27) 
Type "copyright", "credits" or "license" for more information.

IPython 2.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import six

In [2]: six.__version__
Out[2]: '1.4.1'

The solution is to change the PYTHONPATH to use modules you installed from pip. Put the following line to ~/.bash_profile:

export PYTHONPATH="/Library/Python/2.7/site-packages"
knesenko@knesenko-mbp:~$ source .bash_profile 
knesenko@knesenko-mbp:~$ jenkins-jobs 
usage: jenkins-jobs [-h] [--conf CONF] [-l LOG_LEVEL] [--ignore-cache]
                    [--flush-cache] [--version] [--allow-empty-variables]
                    {test,delete-all,update,delete} ...
knesenko@knesenko-mbp:~$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> six.__version__
'1.9.0'
>>> import sys
>>> sys.path
['', '/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']