简体   繁体   English

重新配置作业的Python-jenkins API调用不起作用

[英]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. 我目前正在使用jenkins-python API成功连接到我的jenkins服务器,获取作业的信息,以及获取作业的配置xml。 I am attempting to edit a part of that configuration xml and then push it back up to Jenkins...however, this is not working. 我正在尝试编辑该配置xml的一部分,然后将其推回Jenkins ...但是,这不起作用。 The API call for this exists in reconfig_job , but when I use the following: 用于此的API调用存在于reconfig_job ,但是当我使用以下代码时:

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. 我尝试用于新配置的XML应该很好,因为我可以使用curl来推动新的配置XML并成功更新jenkins作业。

Thanks in advance guys! 在此先感谢大家!

The config_xml in reconfig_job is supposed to be the xml string , not the xml file . config_xmlreconfig_job应该是XML 字符串 ,而不是XML 文件

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.) (顺便说一句,检查您是否打算将字符串'jobname'jobname放入具有工作名称的变量。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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