From 7cadf30d32b0725c884aa30f040eee36d79ff8b4 Mon Sep 17 00:00:00 2001 From: Carl Johnson Date: Mon, 3 Jun 2019 16:25:20 +0100 Subject: [PATCH] Add an example p4 trigger (#65) --- examples/buildkite-trigger.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 examples/buildkite-trigger.sh diff --git a/examples/buildkite-trigger.sh b/examples/buildkite-trigger.sh new file mode 100755 index 0000000..24fbbd4 --- /dev/null +++ b/examples/buildkite-trigger.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -euo pipefail + + +# P4 Trigger script that triggers buildkite builds +# Usage: +# my-pipeline change-commit //depot/... "%//depot/scripts/buildkite-trigger.sh% %changelist% %user% %email%" + +ORG_SLUG=$1 +PIPELINE_SLUG=$2 + +CHANGELIST=$3 +USER=$4 +EMAIL=$5 + +$(p4 -Ztag -F %desc% describe %3) + +PAYLOAD="{ + \"commit\": \"@${CHANGELIST}\", + \"branch\": \"master\", + \"message\": \"${DESCRIPTION}\", + \"author\": { + \"name\": \"${USER}\", + \"email\": \"${EMAIL}\" + } +}" + +curl -H "Authorization: Bearer $BUILDKITE_TOKEN" -X POST "https://api.buildkite.com/v2/organizations/${ORG_SLUG}/pipelines/${PIPELINE_SLUG}/builds" \ + -d "${PAYLOAD}" \ No newline at end of file