← Back to team overview

python-jenkins-developers team mailing list archive

[Bug 1578626] Re: jenkins api error during get_version function call on Jenkins 2.1

 

(toolkits) ➜  jenkins ipython
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
Type "copyright", "credits" or "license" for more information.

IPython 5.0.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 jenkins

In [2]: jenkins_server='http://192.168.56.120:8080'

In [3]: user='admin'

In [4]: token='542294005918b2b8b179036be1b3e260'

In [5]:

In [5]: server=jenkins.Jenkins(
   ...:     jenkins_server,
   ...:     username=user,
   ...:     password=token
   ...: )

In [6]: server.get_version()
---------------------------------------------------------------------------
BadHTTPException                          Traceback (most recent call last)
<ipython-input-6-870b7df143ba> in <module>()
----> 1 server.get_version()

/Users/sebastian/PycharmProjects/envs/toolkits/lib/python2.7/site-packages/jenkins/__init__.pyc in get_version(self)
    614         except (HTTPError, BadStatusLine):
    615             raise BadHTTPException("Error communicating with server[%s]"
--> 616                                    % self.server)
    617
    618     def get_plugins_info(self, depth=2):

BadHTTPException: Error communicating with
server[http://192.168.56.120:8080/]

In [7]: server.get_whoami()
Out[7]:
{u'_class': u'hudson.model.User',
 u'absoluteUrl': u'http://192.168.56.120:8080/user/admin',
 u'description': u'',
 u'fullName': u'Admin',
 u'id': u'admin',
 u'property': [{u'_class': u'jenkins.security.ApiTokenProperty'},
  {u'_class': u'com.cloudbees.plugins.credentials.UserCredentialsProvider$UserCredentialsProperty'},
  {u'_class': u'hudson.tasks.Mailer$UserProperty',
   u'address': u'hello@xxxxxxxxxx'},
  {u'_class': u'hudson.plugins.emailext.watching.EmailExtWatchAction$UserProperty',
   u'triggers': []},
  {u'_class': u'jenkins.security.LastGrantedAuthoritiesProperty'},
  {u'_class': u'hudson.model.MyViewsProperty'},
  {u'_class': u'org.jenkinsci.plugins.displayurlapi.user.PreferredProviderUserProperty'},
  {u'_class': u'hudson.model.PaneStatusProperties'},
  {u'_class': u'hudson.security.HudsonPrivateSecurityRealm$Details'},
  {u'_class': u'org.jenkinsci.main.modules.cli.auth.ssh.UserPropertyImpl'},
  {u'_class': u'hudson.search.UserSearchProperty',
   u'insensitiveSearch': False}]}

still no work?

-- 
You received this bug notification because you are a member of Python
Jenkins Developers, which is subscribed to Python Jenkins.
https://bugs.launchpad.net/bugs/1578626

Title:
  jenkins api  error during get_version function call  on Jenkins 2.1

Status in Python Jenkins:
  New

Bug description:
  i have code which work on server version 1.XX I've upgraded Jenkins to
  2.1 version and now got error.

  string which return exception.

  server = jens.Jenkins(**jenkins_config)
  print("Connected to Jenkins version is: " + server.get_version())
  error is :
  Error communicating with server [..]

  Place in jenkins module where exception occurs:
  string number 498
   except (HTTPError, BadStatusLine):
              raise BadHTTPException("Error communicating with server[%s]"
                                     % self.server)

To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1578626/+subscriptions


References