While using jenkins API, getting a failure on reconfig_job

Bug #1417137 reported by Kuber
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Python Jenkins
New
Undecided
Unassigned

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?

Revision history for this message
Khai Do (zaro0508) wrote :

Could you please provide python-jenkins version and the version of Jenkins?

Revision history for this message
Kranthikurapati (kranthikurapati) wrote :

I am slo facing the issue while working with reconfig_job.Please note that I am able to get all the other information after loggied in to the server using the script. Python-jenkins fails to run reconfig_job only with the modified xml and job name as parametre.

Traceback (most recent call last):
  File "get_build.py", line 47, in <module>
    server.reconfig_job(job1,'jenkins.config_xml')
  File "/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 1019, in reconfig_job
    DEFAULT_HEADERS))
  File "/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 448, in jenkins_open
    e.code, e.msg)
jenkins.JenkinsException: Error in request. Possibly authentication failed [500]: Server Error

Revision history for this message
Rusty Howell (rustyhowell) wrote :

It seems that reconfig_job() only works on Freestyle projects. If the project is a Maven project, Multi-configuration project, or a Multi-job project, (I haven't tested the rest), then the reconfig_job() call will fail with the HTTP 500 error.

Jenkins==2.46.3
python-jenkins==0.4.15
python==3.5.2

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.