While using jenkins API, getting a failure on reconfig_job

Asked by Kuber

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?

Question information

Language:
English Edit question
Status:
Answered
For:
Python Jenkins Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
hqzhon (hqzhon) said :
#1

the api get job config is :
configuration = server.get_job_config(job)

Can you help with this problem?

Provide an answer of your own, or ask Kuber for more information if necessary.

To post a message you must log in.