build objects now have a get_console function
authorsalimfadhley <sal@stodge.org>
Fri, 5 Jul 2013 00:04:35 +0000 (01:04 +0100)
committersalimfadhley <sal@stodge.org>
Fri, 5 Jul 2013 00:04:35 +0000 (01:04 +0100)
jenkinsapi/build.py
jenkinsapi_tests/systests/job_configs.py
jenkinsapi_tests/systests/test_invocation.py
jenkinsapi_tests/systests/test_parameterized_builds.py

index 84db734..fa5c3ae 100644 (file)
@@ -282,6 +282,13 @@ class Build(JenkinsBase):
         naive_timestamp = datetime.datetime(*time.gmtime(self._data['timestamp']/1000.0)[:6])
         return pytz.utc.localize(naive_timestamp)
 
+    def get_console(self):
+        """
+        Return the current state of the text console.
+        """
+        url = "%s/consoleText" % self.baseurl
+        return self.job.jenkins.requester.get_url(url).content
+
     def stop(self):
         """
         Stops the build execution if it's running
index 9d2d547..53de906 100644 (file)
@@ -155,4 +155,4 @@ gzip &lt; out.txt &gt; out.gz</command>
     </hudson.tasks.Fingerprinter>
   </publishers>
   <buildWrappers/>
-</project>""".strip()
\ No newline at end of file
+</project>""".strip()
index f438353..fd4beef 100644 (file)
@@ -31,6 +31,8 @@ class TestInvocation(BaseSystemTest):
         self.assertIsInstance(b, Build)
         ii.stop()
         self.assertFalse(ii.is_running())
+        self.assertIsInstance(ii.get_build().get_console(), str)
+        self.assertIn('Building on master', ii.get_build().get_console())
 
     def test_get_block_until_build_complete(self):
         job_name = 'create_%s' % random_string()
index 7eead9d..3961930 100644 (file)
@@ -70,5 +70,7 @@ class TestParameterizedBuilds(BaseSystemTest):
         artB = artifacts['b.txt']
         self.assertTrue(artB.get_data().strip(), param_B)
 
+        self.assertIn(param_B, b.get_console())
+
 if __name__ == '__main__':
     unittest.main()