Skip to content

Commit

Permalink
Fix 'stop' command fail when there are no builds
Browse files Browse the repository at this point in the history
  • Loading branch information
radomirbosak committed Jun 3, 2017
1 parent b78eaee commit da363fb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions jenkins_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ def builds(self, args):
def stop(self, args):
job_name = self._check_job(args.job_name)
info = self.jenkins.get_job_info(job_name, 1)
build_number = info['lastBuild'].get('number')
if build_number and info['lastBuild'].get('building'):
last_build = info.get('lastBuild') or {}
build_number = last_build.get('number')
if build_number and last_build.get('building'):
stop_status = self.jenkins.stop_build(job_name, build_number)
print("%s: %s" % (job_name, 'stopped' if not stop_status else stop_status))
else:
Expand Down

0 comments on commit da363fb

Please sign in to comment.