← Back to team overview

python-jenkins-developers team mailing list archive

[Bug 1417137] [NEW] While using jenkins API, getting a failure on reconfig_job

 

Public bug reported:

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 server.reconfig_job('GithubMigration', config_xml) 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

AttributeError: 'module' object has no attribute 'Jenkins' for line :
AttributeError: 'module' object has no attribute 'Jenkins'

Any ideas?

** Affects: python-jenkins
     Importance: Undecided
         Status: New

-- 
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/1417137

Title:
  While using jenkins API, getting a failure on reconfig_job

Status in Python API for Jenkins:
  New

Bug description:
  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 server.reconfig_job('GithubMigration', config_xml) 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

  AttributeError: 'module' object has no attribute 'Jenkins' for line :
  AttributeError: 'module' object has no attribute 'Jenkins'

  Any ideas?

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


Follow ups

References