Skip to content

Commit

Permalink
Merge pull request #8 from TwistoPayments/fix-revision
Browse files Browse the repository at this point in the history
fix git revision
  • Loading branch information
Jiri Polansky authored Jun 13, 2019
2 parents 851b5b7 + a8ee999 commit 7280f78
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions jenkinsapi/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ def get_slave(self):
return self._data["builtOn"]

def get_revision(self):
vcs = self._data['changeSet']['kind'] or 'git'
vcs = self._data['changeSets'][0]['kind'] or 'git'
return getattr(self, '_get_%s_rev' % vcs, lambda: None)()

def get_revision_branch(self):
vcs = self._data['changeSet']['kind'] or 'git'
vcs = self._data['changeSets'][0]['kind'] or 'git'
return getattr(self, '_get_%s_rev_branch' % vcs, lambda: None)()

def get_repo_url(self):
vcs = self._data['changeSet']['kind'] or 'git'
vcs = self._data['changeSets'][0]['kind'] or 'git'
return getattr(self, '_get_%s_repo_url' % vcs, lambda: None)()

def get_params(self):
Expand Down Expand Up @@ -162,10 +162,10 @@ def _get_git_rev(self):
# Sometimes we have None as part of actions. Filter those actions
# which have lastBuiltRevision in them
_actions = [x for x in self._data['actions']
if x and "lastBuiltRevision" in x]
if x and "build" in x]

if _actions:
return _actions[0]["lastBuiltRevision"]["SHA1"]
return _actions[0]["build"]["revision"]['SHA1']

return None

Expand All @@ -183,9 +183,9 @@ def _get_git_rev_branch(self):
# Sometimes we have None as part of actions. Filter those actions
# which have lastBuiltRevision in them
_actions = [x for x in self._data['actions']
if x and "lastBuiltRevision" in x]
if x and "build" in x]

return _actions[0]["lastBuiltRevision"]["branch"]
return _actions[0]["build"]["revision"]['branch'][0]['name']

def _get_hg_rev_branch(self):
raise NotImplementedError('_get_hg_rev_branch is not yet implemented')
Expand Down

0 comments on commit 7280f78

Please sign in to comment.