bitbucket-webhook

command module
v0.0.0-...-c71a8f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 13 Imported by: 0

README

Bitbucket Webhook

Simple webhook listener for Bitbucket webhooks that executes configurable shell commands when a webhook is triggered.

Usage

    bitbucket-webhook [-config "<config-file>"] [-listen "<[host]:port>"]] [-secret "<secret>"]

Note: Command line arguments take higher precedance over configuration file options.

Configuration File

listen: ":3000"
secret: "my$ecret"
hooks:
- event: "event:key"
  async: false
  command: /bin/bash
  args:
  - "-c"
  - echo "Hello World"

Templating

The args support go template syntax and were populated with the entire Webhook payload object.

Example

hooks:
- event: "pr:merged"
  command: /bin/bash
  args:
  - "-c"
  - echo "There's a merged PR from {{ .author.name }}"

See Bitbucket: Event Payload for more Details.

Example Webhook Requests

Note: The body is just a minimalistic - but correct - subset of the actual bitbucket pr:merged webhook payload.

BODY='{ "actor" : { "name" : "Peter Müller" }}' 
SIG="$(echo -n $BODY | openssl dgst -sha256 -hmac secret)" 
curl -XPOST -H "X-Request-Id: $(uuidgen)" -H "X-Event-Key: pr:merged" -H "X-Hub-Signature: $SIG" -v --data "$BODY" http://localhost:3000/webhook

or as one-liner

BODY='{ "actor" : { "name" : "Peter Müller" }}' SIG="$(echo -n $BODY | openssl dgst -sha256 -hmac secret)" bash -c 'curl -XPOST -H "X-Request-Id: $(uuidgen)" -H "X-Event-Key: pr:merged" -H "X-Hub-Signature: $SIG" -v --data "$BODY" http://localhost:3000/webhook'

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL