scm_url.text = new_source_url
self.update_config(ET.tostring(element_tree))
+ def get_config_xml_url(self):
+ return '%s/config.xml' % self.baseurl
+
def update_config(self, config):
"""
Update the config.xml to the job
Also refresh the ElementTree object since the config has changed
"""
- post_data = self.post_data("%(baseurl)s/config.xml" % self.__dict__, config)
+ url = self.get_config_xml_url()
+ response = self.jenkins.requester.post_url(url, params={}, data='')
self._element_tree = ET.fromstring(config)
- return post_data
+ return response.text
def get_downstream_jobs(self):
"""
self.jenkins.create_job(job_name, EMPTY_JOB_CONFIG)
self.assertJobIsPresent(job_name)
- def test_get_job_config(self):
+ def test_get_job_and_update_config(self):
job_name = 'config_%s' % random_string()
self.jenkins.create_job(job_name, EMPTY_JOB_CONFIG)
self.assertJobIsPresent(job_name)
config = self.jenkins[job_name].get_config()
self.assertEquals(config.strip(), EMPTY_JOB_CONFIG.strip())
+ self.jenkins[job_name].update_config(EMPTY_JOB_CONFIG)
def test_invoke_job(self):
job_name = 'create_%s' % random_string()
--- /dev/null
+'''
+System tests for `jenkinsapi.jenkins` module.
+'''
+import time
+import unittest
+from jenkinsapi_tests.test_utils.random_strings import random_string
+from jenkinsapi_tests.systests.base import BaseSystemTest
+
+PINGER_JOB_CONFIG = """
+<?xml version='1.0' encoding='UTF-8'?>
+<project>
+ <actions/>
+ <description>Ping a load of stuff for about 10s</description>
+ <keepDependencies>false</keepDependencies>
+ <properties/>
+ <scm class="hudson.scm.NullSCM"/>
+ <canRoam>true</canRoam>
+ <disabled>false</disabled>
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
+ <triggers class="vector"/>
+ <concurrentBuild>false</concurrentBuild>
+ <builders>
+ <hudson.tasks.Shell>
+ <command>ping -c 5 localhost | tee out.txt</command>
+ </hudson.tasks.Shell>
+ </builders>
+ <publishers>
+ <hudson.tasks.ArtifactArchiver>
+ <artifacts>*.txt</artifacts>
+ <latestOnly>false</latestOnly>
+ </hudson.tasks.ArtifactArchiver>
+ </publishers>
+ <buildWrappers/>
+</project>""".strip()
+
+class TestPingerJob(BaseSystemTest):
+
+ def test_invoke_job(self):
+ job_name = 'create_%s' % random_string()
+ job = self.jenkins.create_job(job_name, PINGER_JOB_CONFIG)
+ job.invoke(block=True)
+
+ b = job.get_last_build()
+
+ while b.is_running():
+ time.sleep(0.25)
+
+ artifacts = b.get_artifact_dict()
+ self.assertIsInstance(artifacts, dict)
+
+ outfile = artifacts['out.txt']
+
+ # TODO: Actually verify the download
+
+
+if __name__ == '__main__':
+ unittest.main()