|
|
|
@ -34,6 +34,16 @@ BUILDBUCKET_API_URL = urlparse.urljoin(
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_common_arguments(parser):
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--response-json',
|
|
|
|
|
help=(
|
|
|
|
|
'A path to which the response JSON will be written. '
|
|
|
|
|
'If no valid JSON is received, nothing will be written.'
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(argv):
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
parser.add_argument(
|
|
|
|
@ -42,13 +52,17 @@ def main(argv):
|
|
|
|
|
action='store_true',
|
|
|
|
|
)
|
|
|
|
|
subparsers = parser.add_subparsers(dest='command')
|
|
|
|
|
|
|
|
|
|
get_parser = subparsers.add_parser('get')
|
|
|
|
|
add_common_arguments(get_parser)
|
|
|
|
|
get_parser.add_argument(
|
|
|
|
|
'--id',
|
|
|
|
|
help='The ID of the build to get the status of.',
|
|
|
|
|
required=True,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
put_parser = subparsers.add_parser('put')
|
|
|
|
|
add_common_arguments(put_parser)
|
|
|
|
|
put_parser.add_argument(
|
|
|
|
|
'-b',
|
|
|
|
|
'--bucket',
|
|
|
|
@ -77,7 +91,9 @@ def main(argv):
|
|
|
|
|
'from another command.'
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
retry_parser = subparsers.add_parser('retry')
|
|
|
|
|
add_common_arguments(retry_parser)
|
|
|
|
|
retry_parser.add_argument(
|
|
|
|
|
'--id',
|
|
|
|
|
help='The ID of the build to retry.',
|
|
|
|
@ -153,11 +169,15 @@ def main(argv):
|
|
|
|
|
print 'Content:', content
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
build_url = json.loads(content)['build']['url']
|
|
|
|
|
content_json = json.loads(content)
|
|
|
|
|
if args.response_json:
|
|
|
|
|
with open(args.response_json, 'w') as response_json_file:
|
|
|
|
|
response_json_file.write(content)
|
|
|
|
|
build_url = content_json['build']['url']
|
|
|
|
|
except (ValueError, TypeError, KeyError):
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
print 'Build triggered on: %s' % build_url
|
|
|
|
|
print 'Build: %s' % build_url
|
|
|
|
|
|
|
|
|
|
return response.status != 200
|
|
|
|
|
|
|
|
|
|