def run():
  current_branch = Repo(os.getcwd()).active_branch
  api = CircleCiAPIGateway(token=os.environ['CIRCLE_TOKEN'])
  builds_canceled = 0
  owner, repo = Helper.owner_and_repo()

  for build in api.call('recent_branch_builds', username=owner, project=repo, branch=current_branch)[0]:
    if build['status'] in ['running', 'not_running', 'queued', 'scheduled']:
      api.call('cancel_build', username=owner, project=repo, build_num=build['build_num'])
      builds_canceled += 1

  print '{0} builds canceled'.format(builds_canceled)
def run():
  current_branch = Repo(os.getcwd()).active_branch
  api = CircleCiAPIGateway(token=os.environ['CIRCLE_TOKEN'])
  owner, repo = Helper.owner_and_repo()
  result = api.call('new_build', username=owner, project=repo, branch=current_branch)[0]
  if result.get('build_url') is not None:
    print result['build_url']
  else:
    if result.get('message') is not None:
      print result['message']
    else:
      print result
Beispiel #3
0
  def _cancel_circleci(self):
    variable_name = 'CIRCLE_TOKEN'
    circle_token = os.environ.get(variable_name)
    builds_canceled = 0
    if circle_token is not None:
      api = CircleCiAPIGateway(token = circle_token)
      owner, repo = self._helper2.owner_and_repo()
      for build in api.call('recent_branch_builds', username=owner, project=repo, branch=self._branch)[0]:
        if build['status'] in ['running', 'not_running', 'queued', 'scheduled']:
          api.call('cancel_build', username=owner, project=repo, build_num=build['build_num'])
          builds_canceled += 1
    else:
      print('The environment variable ${0} is not set so canceling tests is impossible'.format(variable_name))

    return builds_canceled