简体   繁体   中英

Python-jenkins API call to reconfig job not working

I am currently using the jenkins-python API to connect to my jenkins server, get a job's info, and get a job's configuration xml all through this API successfully. I am attempting to edit a part of that configuration xml and then push it back up to Jenkins...however, this is not working. The API call for this exists in reconfig_job , but when I use the following:

jenkinsServer.reconfig_job('jobname', 'xmlFile.xml')

I get no output from running this, no failures, no exceptions, nothing...but when I go to look at my jenkins job, the configuration has not changed. Since there are no messages here, not really sure what the issue is.

The XML i'm attempting to use for the new configuration should be fine, because I can use curl to push the new config XML up and that successfully updates the jenkins job.

Thanks in advance guys!

The config_xml in reconfig_job is supposed to be the xml string , not the xml file .

So in your case, do:

with open('xmlFile.xml', 'r') as xml_file:
    config_data = xml_file.read()
jenkinsServer.reconfig_job('jobname', config_data)

(Btw, check if you meant to put the string 'jobname' vs jobname the variable which has the job's name.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM