about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-11-04T14·16+0100
committerVincent Ambo <mail@tazj.in>2021-11-04T14·16+0100
commit00ae396eeb0f6962a8a4bff21ec8ee039c0abaf7 (patch)
tree68212a0bbbe994d63c244822a97f1a62902e7fb5
parentbbf92dcdeaaf8bd8ab43fdd167f0709bb8840eb6 (diff)
feat(ops/pipelines): Create revision numbers in CI r/2999
This automatically pushes a new ref at refs/r/$revision to Gerrit
whenever a CI run completes on canon.

Revision numbers can be fetched from Gerrit with this command:

    git fetch gerrit "refs/r/*:refs/r/*"

Note that this build step requires credentials to be provisioned on
the CI runner machine.

Change-Id: I37bb14346832f891240aa47bb55affaace3d5f21
-rw-r--r--ops/pipelines/depot.nix14
1 files changed, 14 insertions, 0 deletions
diff --git a/ops/pipelines/depot.nix b/ops/pipelines/depot.nix
index 6d4b69d5b0..7c72098b9d 100644
--- a/ops/pipelines/depot.nix
+++ b/ops/pipelines/depot.nix
@@ -116,5 +116,19 @@ let
           allow_failure = false;
         }];
       })
+
+      # Create a revision number for the current commit for builds on
+      # canon.
+      #
+      # This writes data back to Gerrit using the Buildkite agent
+      # credentials injected through a git credentials helper.
+      #
+      # Revision numbers are defined as the number of commits in the
+      # lineage of HEAD, following only the first parent of merges.
+      ({
+        command = "git -c 'credential.helper=/etc/secrets/buildkite-credential-helper' push origin \"HEAD:refs/r/$(git rev-list --count --first-parent HEAD)\"";
+        label = ":git:";
+        "if" = ''build.branch == "refs/heads/canon"'';
+      })
     ];
 in (writeText "depot.yaml" (toJSON pipeline))