Skip to content

Commit

Permalink
Add an example p4 trigger (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
ca-johnson authored Jun 3, 2019
1 parent 07d22f4 commit 7cadf30
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions examples/buildkite-trigger.sh
Original file line number Diff line number Diff line change
@@ -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% <organisation> <pipeline> %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}"

0 comments on commit 7cadf30

Please sign in to comment.