Skip to content

Commit

Permalink
Merge pull request #11 from TwistoPayments/release-0.3.9.twisto.4
Browse files Browse the repository at this point in the history
Changes of
  • Loading branch information
Jiri Polansky authored Oct 15, 2019
2 parents 70313bf + ece9f80 commit 1af11c7
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions jenkinsapi/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,30 @@ def get_slave(self):
return self._data["builtOn"]

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

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

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

def get_params(self):
Expand Down Expand Up @@ -143,13 +155,11 @@ def get_changeset_items(self):
}
"""
if 'changeSet' in self._data:
for i in self._data['changeSet']:
if 'items' in i:
return i['items']
if 'items' in self._data['changeSet']:
return self._data['changeSet']['items']
elif 'changeSets' in self._data:
for i in self._data['changeSets']:
if 'items' in i:
return i['items']
if 'items' in self._data['changeSets']:
return self._data['changeSets']['items']
return []

def _get_svn_rev(self):
Expand All @@ -165,10 +175,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 "build" in x]
if x and "lastBuiltRevision" in x]

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

return None

Expand All @@ -186,9 +196,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 "build" in x]
if x and "lastBuiltRevision" in x]

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

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

0 comments on commit 1af11c7

Please sign in to comment.