Commit 64a001ef authored by Sergiy Belozorov's avatar Sergiy Belozorov Committed by Commit Bot

Add support for retry command to buildbucket.py

R=nodir@chromium.org

Bug: 911143
Change-Id: Ia506f51687a7e4636e16746483931298dfd22027
Reviewed-on: https://chromium-review.googlesource.com/c/1356520Reviewed-by: 's avatarNodir Turakulov <nodir@chromium.org>
Commit-Queue: Sergiy Belozorov <sergiyb@chromium.org>
parent d87b0966
......@@ -20,6 +20,7 @@ import json
import urlparse
import os
import sys
import time
from third_party import httplib2
......@@ -76,6 +77,13 @@ def main(argv):
'from another command.'
),
)
retry_parser = subparsers.add_parser('retry')
retry_parser.add_argument(
'--id',
help='The ID of the build to retry.',
required=True,
)
args = parser.parse_args()
body = None
......@@ -117,6 +125,9 @@ def main(argv):
})
method = 'PUT'
url = BUILDBUCKET_API_URL
elif args.command == 'retry':
method = 'PUT'
url = '%s/%s/retry' % (BUILDBUCKET_API_URL, args.id)
authenticator = auth.get_authenticator_for_host(
BUILDBUCKET_URL,
......@@ -124,6 +135,12 @@ def main(argv):
)
http = authenticator.authorize(httplib2.Http())
http.force_exception_to_status_code = True
if args.verbose:
print 'Request URL:', url
print 'Request method:', method
print 'Request body:', body
response, content = http.request(
url,
method,
......@@ -132,10 +149,14 @@ def main(argv):
)
if args.verbose:
print content
build_url = json.loads(content).get('build', {}).get('url')
if build_url:
print 'Response:', response
print 'Content:', content
try:
build_url = json.loads(content)['build']['url']
except (ValueError, TypeError, KeyError):
pass
else:
print 'Build triggered on: %s' % build_url
return response.status != 200
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment