I would like to programmatically update a job configuration by Jenkins API.
Is there a .xsd file for jenkins job configuration so that I can use it to generate a java class and in turn manipulate this java class to update jenkins job configuration?
If not, could you advise me with some more convenient way to do this?
Thanks.
I have always created a template job using the Jenkins Web UI and then downloaded a copy of the configuration file from $JENKINS_URL/job/JOBNAME/config.xml
When I want to create jobs from this template, I use xml-sed (from xml coretools) to replace the values I need and then pipe it into Jenkins CLI create-job command (see $JENKINS_URL/cli/ for more information) to create new jobs. The same method can be used to update existing jobs.
It is also possible to use the Jenkins script console and execute Groovy scripts that can manipulate the internal java objects which represent jobs but I have found that to be somewhat difficult. With enough staring at http://javadoc.jenkins-ci.org/ and experimenting with script console it is definitely doable, but I would still recommend the config.xml manipulation, if for no other reason than it's easier to script it and the config.xml files can be stored in version control.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句