write some basic metadata values as early as possible

There are a few metadata values that, if they are missing from
metadata.json, make the metadata file break gather_builder_stats. Now
that the metadata object is preserved across cbuildbot re-executions,
write some important values to metadata as soon as possible (at the very
beginning of the run) rather than waiting until after a SyncStage has
run.

BUG=chromium:369748
TEST=local tryjobs; new unit test

Change-Id: I91b7386772ee0db2256ff97223dd79bb00c947fd
Reviewed-on: https://chromium-review.googlesource.com/206589
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 885e40c..ab15fd4 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -357,6 +357,8 @@
     Returns:
       Whether the build succeeded.
     """
+    report_stages.WriteBasicMetadata(self._run)
+
     self._InitializeTrybotPatchPool()
 
     if self._run.options.bootstrap: