From 7b7780bc86da31bea78c3ba77064b72130296602 Mon Sep 17 00:00:00 2001 From: timp21337 Date: Tue, 17 Jun 2014 17:47:55 +0100 Subject: [PATCH] Example of adding a shell build --- examples/how_to/add_command.py | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 examples/how_to/add_command.py diff --git a/examples/how_to/add_command.py b/examples/how_to/add_command.py new file mode 100644 index 0000000..fadfa02 --- /dev/null +++ b/examples/how_to/add_command.py @@ -0,0 +1,40 @@ +from jenkinsapi.jenkins import Jenkins +import xml.etree.ElementTree as ET + +J = Jenkins('http://localhost:8080') +EMPTY_JOB_CONFIG = ''' + + + jkkjjk + + false + + + true + false + false + false + + false + + + + +''' + +jobname = 'foo_job' +new_job = J.create_job(jobname, EMPTY_JOB_CONFIG) +new_conf = new_job.get_config() + +root = ET.fromstring(new_conf.strip()) + +builders = root.find('builders') +shell = ET.SubElement(builders, 'hudson.tasks.Shell') +command = ET.SubElement(shell, 'command') +command.text = "ls" + +print ET.tostring(root) +J[jobname].update_config(ET.tostring(root)) + +#J.delete_job(jobname) + -- 2.34.1