cbuildbot: archive the manifest we used

Since the exact manifest a bot used to build is useful to developers,
add a step to do that in the ArchiveStage.  The file is tiny so it
shouldn't really impact things.

BUG=None
TEST=Set the snapshot_manifest parameter and make
     sure that buildbot makes manifest snapshots

Change-Id: Ib0a440fcac25a74aed74742b6a20a8a71b34595c
Reviewed-on: https://chromium-review.googlesource.com/49825
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/buildbot/cbuildbot_stages.py b/buildbot/cbuildbot_stages.py
index a1c7c49..b81283d 100644
--- a/buildbot/cbuildbot_stages.py
+++ b/buildbot/cbuildbot_stages.py
@@ -3257,9 +3257,17 @@
     #          \- ArchiveZipFiles
     #          \- ArchiveHWQual
     #       \- PushImage (blocks on BuildAndArchiveAllImages)
+    #    \- ArchiveManifest
     #    \- ArchiveStrippedChrome
     #    \- ArchiveImageScripts
 
+    def ArchiveManifest():
+      """Create manifest.xml snapshot of the built code."""
+      output_manifest = os.path.join(archive_path, 'manifest.xml')
+      cmd = ['repo', 'manifest', '-r', '-o', output_manifest]
+      cros_build_lib.RunCommand(cmd, cwd=buildroot, capture_output=True)
+      self._upload_queue.put(['manifest.xml'])
+
     def BuildAndArchiveFactoryImages():
       """Build and archive the factory zip file.
 
@@ -3394,7 +3402,6 @@
           sign_types=sign_types)
       self._push_image_status_queue.put(urls)
 
-
     def ArchiveReleaseArtifacts():
       with self.ArtifactUploader(self._release_upload_queue, archive=False):
         steps = [BuildAndArchiveAllImages, ArchiveFirmwareImages]
@@ -3403,7 +3410,7 @@
 
     def BuildAndArchiveArtifacts():
       # Run archiving steps in parallel.
-      steps = [ArchiveReleaseArtifacts]
+      steps = [ArchiveReleaseArtifacts, ArchiveManifest]
       if config['images']:
         steps.extend([self.ArchiveStrippedChrome, ArchiveImageScripts])
       if config['create_delta_sysroot']: