How to Install Jenknis API for Python

579 views
Skip to first unread message

joshuam...@gmail.com

unread,
Dec 3, 2013, 6:37:46 PM12/3/13
to jenkins...@googlegroups.com
Hello,

  I'm new to Jenkins and use python only to run test scripts on our custom test executive. We use Python 3.2 and we wrote software to allow python to communicate with our test executive. I'm trying to figure out how to install the Jenkins API for python. First I looked into PIP and came across 2 issues: 1) I don't use CPython and 2) It presents me with the same install issues as the Jenkins API. Can I merely unzip the API, and drag the jenkinsapi folder to a specific directory path? Any help would be appreciated.

Joshua Marberry
Test Software Developer
RED Digital Cinema
 

JonathanRRogers

unread,
Dec 4, 2013, 9:38:29 PM12/4/13
to jenkins...@googlegroups.com


On Tuesday, December 3, 2013 6:37:46 PM UTC-5, joshuam...@gmail.com wrote:
Hello,

  I'm new to Jenkins and use python only to run test scripts on our custom test executive. We use Python 3.2 and we wrote software to allow python to communicate with our test executive. I'm trying to figure out how to install the Jenkins API for python. First I looked into PIP and came across 2 issues: 1) I don't use CPython and 2) It presents me with the same install issues as the Jenkins API. Can I merely unzip the API, and drag the jenkinsapi folder to a specific directory path? Any help would be appreciated.

What Python implementation do you use? Does pip not work at all? AFAIK, jenkinsapi is pure Python.

joshuam...@gmail.com

unread,
Dec 5, 2013, 2:27:08 PM12/5/13
to jenkins...@googlegroups.com
Jonathan,

thanks for the reply. I do believe I installed the api using easy_install. Now I'm in the stage trying to verify that the API actually works. The biggest problem here is I'm still very green to Python. The implementation I'm running is 3.2 taken from http://www.python.org/download/releases/3.2/ and I'm running on Windows 7 64 bit.

Thanks for your help,

Josh

Jonathan Rogers

unread,
Dec 5, 2013, 2:56:31 PM12/5/13
to jenkins...@googlegroups.com
OK, you are using CPython then. That is the original and official
implementation of Python. As you may know, there are two major branches
of CPython. Python 3.x was intended to make deep, incompatible changes
to improve or fix long-known problems or limitations in 2.x. Therefore,
some code that works on 2.7 won't work on 3.2 and vice-versa. Many
projects still only work on 2.x, apparently including jenkinsapi
according to the pypi listing.

I'm not sure what your exact problem has been, but you should try using
jenkinsapi with Python 2.7. It is possible to have more than one version
of Python installed so that different programs can use one or the other.
I haven't done so on Windows, but I have multiple versions built from
source on Unix-like systems. It looks like it should be even easier on
Windows because the official installers install to directories including
version number. The following guide looks like it should be helpful. I
strongly recommend using pip and virtualenv, which HOWTO also covers.

<URL:http://docs.python-guide.org/en/latest/starting/install/win/>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Jenkins Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jenkinsci-users/wn0dLXNgWqE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> jenkinsci-use...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


--
Jonathan Rogers

joshuam...@gmail.com

unread,
Dec 5, 2013, 4:10:51 PM12/5/13
to jenkins...@googlegroups.com
Jonathan,

  again thanks for the information. Unfortunately, using python 2.7 is out of the question. The scripts have to work with our test executive which is compatible with python 3.2. I will have to go down another avenue to complete my task unless they have a version of Jenkins api that works with python 3.2. Thanks for all the information. It was a great help.

Josh

Jonathan Rogers

unread,
Dec 5, 2013, 4:39:58 PM12/5/13
to jenkins...@googlegroups.com
I don't think you've said exactly what your problem is. Were you not
able to install jenkinsapi? Were you unable to connect to Jenkins using
it? I'm not sure using Python 2.7 is out of the question, since one
script can run another in a subprocess, though I don't know how much of
a hassle that would be in your situation.

I have only tried jenkinsapi with Python 2.7 so I don't know to what
extent it will or will not work with 3.2. It looks like there has
already been some work done to make it work with 3.x, so I'd try that
before giving up.

<URL:https://github.com/salimfadhley/jenkinsapi/pull/81>
> <http://docs.python-guide.org/en/latest/starting/install/win/>>
> <https://groups.google.com/d/topic/jenkinsci-users/wn0dLXNgWqE/unsubscribe>.
>
> > To unsubscribe from this group and all its topics, send an email to
> > jenkinsci-use...@googlegroups.com <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
> --
> Jonathan Rogers

joshuam...@gmail.com

unread,
Dec 5, 2013, 4:52:36 PM12/5/13
to jenkins...@googlegroups.com
I was able to run easy_install to get the Jenkins api and it placed python_jenkins-0.2.1-py3.2.egg at C:\Python32\Lib\site-packages. I just found out that the file is some sort of a zip file. I changed the extension to .zip and unzipped it. I found very little in there though. There was just an _init_.py file in 1 folder and dependency_links.txt, PKG-INFO, SOURCES.txt, top_level.txt and zip-safe file in another folder. I'm no programming genius, but it doesn't look like this isn enough to be the api. I have tried running scripts with
import jenkinsapi at the top and the script fails. But, if I comment it out, the rest of the script will run, which tells me that the api isn't installed right or isn't working.

Jonathan Rogers

unread,
Dec 5, 2013, 5:58:18 PM12/5/13
to jenkins...@googlegroups.com
Based on the discussion I linked to, it doesn't look like the stable
release of jenkinsapi available via pip or easy_install works with
Python 3.x yet. I would guess that easy_install failed to fully install
jenkinsapi because of 3.x-incompatible code. So, in this case, you will
probably need to get dechols' jenkinsapi fork from his repository:
<URL:https://github.com/dechols/jenkinsapi>

Once you have downloaded the package in a zip file or using git, the
official docs cover how to install it:
<URL:http://docs.python.org/3/install/> <http://docs.python.org/3/install/>
> <https://github.com/salimfadhley/jenkinsapi/pull/81>>

joshuam...@gmail.com

unread,
Dec 5, 2013, 7:54:33 PM12/5/13
to jenkins...@googlegroups.com

Jonathan,

  I got Jenkins api from dechols path and unzipped it. It still didn't work. So I went through each .py file and changed every except x, y: to except x as y:. It installed. My script doesn't crash with the line 'import jenkinsapi' at the top. But, it fails when the line 'from jenkinsapi.jenkins import Jenkins' follows. I think more needs to be updated in the py files. I'm trying to get ahold of 2to3 which converts python files from 2 to 3. Hopefully, this will work.

Josh

joshuam...@gmail.com

unread,
Dec 5, 2013, 8:49:59 PM12/5/13
to jenkins...@googlegroups.com
Jonathan,

  I ran the 2to3.py script that comes with the python 3.2 install on the entire unzipped jenkinsapi folder and then reinstalled the api. It appears that I can connect to the Jenkins server. Thanks for all your help.

Josh

Jonathan Rogers

unread,
Dec 6, 2013, 12:07:49 AM12/6/13
to jenkins...@googlegroups.com
Great. Yeah, it's quite possible that what you did is exactly what
dechols intended. I know that one way of maintaining a codebase to be
both Python 2.x and 3.x compatible is to keep it 2.x compatible, but
also ensure that running 2to3 over it will produce 3.x-compatible code.
Reply all
Reply to author
Forward
0 new messages