summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalim Fadhley <sal@stodge.org>2014-08-30 00:49:36 +0100
committerSalim Fadhley <sal@stodge.org>2014-08-30 00:49:36 +0100
commit2a2960b118efc902e894e753cde915de96bba5b4 (patch)
treef3515e3ec96983348431dc0f097029f76350e786
parenta7fca527ab2dfb2b8b7841b246289821303ce15b (diff)
parentafbec4936bb868a1fa24ca50c445f8f5173cc4d4 (diff)
downloadpython-jenkinsapi-2a2960b118efc902e894e753cde915de96bba5b4.tar.gz
python-jenkinsapi-2a2960b118efc902e894e753cde915de96bba5b4.tar.bz2
python-jenkinsapi-2a2960b118efc902e894e753cde915de96bba5b4.zip
Merge pull request #250 from toumorokoshi/master
get_revision raises error when querying a job with no SCM
-rw-r--r--jenkinsapi/build.py5
-rw-r--r--jenkinsapi_tests/unittests/test_build.py4
2 files changed, 8 insertions, 1 deletions
diff --git a/jenkinsapi/build.py b/jenkinsapi/build.py
index 122616f..1f07e69 100644
--- a/jenkinsapi/build.py
+++ b/jenkinsapi/build.py
@@ -89,7 +89,10 @@ class Build(JenkinsBase):
_actions = [x for x in self._data['actions']
if x and "lastBuiltRevision" in x]
- return _actions[0]["lastBuiltRevision"]["SHA1"]
+ if len(_actions) > 0:
+ return _actions[0]["lastBuiltRevision"]["SHA1"]
+
+ return None
def _get_hg_rev(self):
warnings.warn("This untested function may soon be removed from Jenkinsapi (_get_hg_rev).")
diff --git a/jenkinsapi_tests/unittests/test_build.py b/jenkinsapi_tests/unittests/test_build.py
index 5fe8648..817db97 100644
--- a/jenkinsapi_tests/unittests/test_build.py
+++ b/jenkinsapi_tests/unittests/test_build.py
@@ -86,6 +86,10 @@ class test_build(unittest.TestCase):
build = Build('http://halob:8080/job/foo/98', 98, self.j, depth=0)
get_data_mock.assert_called_with('http://halob:8080/job/foo/98/api/python?depth=0')
+ def test_get_revision_no_scm(self):
+ """ with no scm, get_revision should return None """
+ self.assertEqual(self.b.get_revision(), None)
+
## TEST DISABLED - DOES NOT WORK
# def test_downstream(self):
# expected = ['SingleJob','MultipleJobs']