Allow archive bucket to be specified on the command line.

This will be used by chromium cros trybots running on the chromium
tryserver to specify a different bucket
to upload their artifacts to, so they don't conflict with chromeos
chromium trybots running on the chromeos tryserver.

BUG=chromium-os:31611
TEST=Remote trybot

Change-Id: I6f4b9557339af942de322df48b99b3330dd0e470
Reviewed-on: https://gerrit.chromium.org/gerrit/26066
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Ryan Cui <rcui@chromium.org>
Tested-by: Ryan Cui <rcui@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index db62c0b..6a4eaad 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -680,12 +680,23 @@
 
   return expanded
 
+# pylint: disable=W0613
+def check_gs_path(option, opt, value):
+  """Expand paths and make them absolute."""
+  value = value.strip().rstrip('/')
+  if not value.startswith('gs://'):
+    raise optparse.OptionValueError('Invalid gs path %s specified for %s'
+                                    % (value, opt))
+
+  return value
+
 
 class CustomOption(optparse.Option):
   """Subclass Option class to implement pass-through and path evaluation."""
-  TYPES = optparse.Option.TYPES + ('path',)
+  TYPES = optparse.Option.TYPES + ('path', 'gs_path')
   TYPE_CHECKER = optparse.Option.TYPE_CHECKER.copy()
   TYPE_CHECKER['path'] = check_path
+  TYPE_CHECKER['gs_path'] = check_gs_path
 
   ACTIONS = optparse.Option.ACTIONS + ('extend',)
   STORE_ACTIONS = optparse.Option.STORE_ACTIONS + ('extend',)
@@ -772,6 +783,9 @@
       'Advanced Options',
       'Caution: use these options at your own risk.')
 
+  # The base GS URL (gs://<bucket_name>/<path>) to archive artifacts to.
+  group.add_remote_option('--archive-base', type='gs_path',
+                          help=optparse.SUPPRESS_HELP)
   # bootstrap-args are not verified by the bootstrap code.  It gets passed
   # direcly to the bootstrap re-execution.
   group.add_remote_option('--bootstrap-args', action='append',