While using jenkins API, getting a failure on reconfig_job


I am using jenkins rest API to recurse through jobs and then reconfigure this one. All methods work except one. He's is my code :

def get_server_instance(): jenkins_url = 'xxxx' #server = Jenkins(jenkins_url, username = '', password = '') # Connect to instance - username and password are optional server = jenkins.Jenkins(jenkins_url, username = '', password = '') return server def get_job_details(): # Refer Example #1 for definition of function 'get_server_instance' server = get_server_instance() for job in server.get_jobs_list(): if job == "GithubMigration": configuration = server.get_job(job).get_config().encode('utf-8') #server.reconfig_job(job, configuration) if server.has_job("GithubMigration"): server.reconfig_job('GithubMigration', config_xml)

It gets my configuration.xml, find the job as well but fails on <strong>server.reconfig_job('GithubMigration', config_xml)</strong> with the error , AttributeError: 'Jenkins' object has no attribute 'reconfig_job'

when obviously this functions exists in the jenkins rest API and yes I'm importing jenkins, from jenkinsapi.jenkins import Jenkins .

Edit 1 - I uninstalled Jenkinsapi and have only python-jenkins module and now it fails even before saying

<strong><em>AttributeError: 'module' object has no attribute 'Jenkins' for line : AttributeError: 'module' object has no attribute 'Jenkins'</em></strong>

Any ideas?

Edit 2 :

I tries solely python-jenkins API and tried their own example as you see here <a href="http://python-jenkins.readthedocs.org/en/latest/example.html" rel="nofollow">http://python-jenkins.readthedocs.org/en/latest/example.html</a>

import jenkins j = jenkins.Jenkins('http://your_url_here', 'username', 'password') j.get_jobs() j.create_job('empty', jenkins.EMPTY_CONFIG_XML) j.disable_job('empty') j.copy_job('empty', 'empty_copy') j.enable_job('empty_copy') j.reconfig_job('empty_copy', jenkins.RECONFIG_XML)

Even this fails at jenkins.Jenkins with attribute error at Jenkins - No module.

I am pretty sure the API is broken.


Your script is probably importing wrong module. You can check it as follows:

import jenkins print jenkins.__file__

If printed path is other than installation path of jenkins module (eg. C:\Python27_32\lib\site-packages\jenkins\__init__.pyc), then you should check pythonpath:

import sys print sys.path

Common problem is existence of python script with same name as imported module in current directory, which is at the first place in search path ''.

For more info on import order see <a href="https://docs.python.org/2/tutorial/modules.html#the-module-search-path" rel="nofollow">module search path</a>


  • Why my jwt tokens never expire?
  • Explicitly illegal character sequence in python code
  • Moving elements by dragging in Dart
  • how to populate gridview from ajax call using Yii2
  • Should the plus in tel URIs be encoded?
  • How to set charset in Apache Chemistry CMIS API?
  • \" instead sign of quote (\")
  • Validate a base64 decoded image in laravel
  • How to decode gzip encoded html?
  • can we assign object into cookie in javascript?
  • Is there a way using jQuery to submit a form without the elaborate field by field breakdown?
  • (de)compress base64 string
  • how to pass credentials with angular-http-auth?
  • Messaging Protocol
  • Pass javascript variable into php code
  • Special Characters on Console
  • Ignoring certain characters while looping through CSV rows
  • Converting C-Strings from Local Encoding to UTF8
  • How to mock springSecurityService in unit tests using grails
  • Convert hex to utf in Python
  • Python-3 Request parameter encoding error
  • Retrieving a contacts notes
  • Special chars in Amazon S3 keys?
  • Encode Byte array to JPEG image in Objective-C
  • Serve file to user over http via php
  • JBoss External Properties Files in Classpath
  • Android - Material Design - NavigationView - How to put vertical scroll?
  • Xcode 4 NSLog Macro link in Xcode 3
  • Play WS (2.2.1): post/put large request
  • Jquery UI tool tip close icon
  • SSO with signing and signature validation doesn't work
  • Deserializing XML into class C#
  • Is there a mandatory requirement to switch app.yaml?
  • Acquiring multiple attributes from .xml file in c#
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is there any way to bind data to data.frame by some index?
  • costura.fody for a dll that references another dll
  • How can i traverse a binary tree from right to left in java?
  • How to Embed XSL into XML