bitbucket-webhook

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

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

Go to latest
Published: Feb 13, 2026 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.

Docker

docker run -it --volume ./config.yaml:/config.yaml -p 3000:3000 ghcr.io/petermue/bitbucket-webhook:latest -config /config.yaml -secret "your-secret"

Or using environment variables with a configuration file:

docker run -it \
  --volume ./config.yaml:/config.yaml \
  -p 3000:3000 \
  ghcr.io/petermue/bitbucket-webhook:latest

The image is available on GitHub Container Registry (GHCR).

Configuration File

listen: ":3000"
secret: "my$ecret"
hooks:
- event: "event:key"
  async: false
  command: /bin/sh
  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/sh
  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.

SECRET='secret'
BODY='{ "actor" : { "name" : "Peter Müller" }}' 
SIG="$(echo -n $BODY | openssl dgst -sha256 -hmac $SECRET -binary | xxd -p -c 256)" 
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

SECRET='secret' BODY='{ "actor" : { "name" : "Peter Müller" }}' SIG="$(echo -n $BODY | openssl dgst -sha256 -hmac $SECRET -binary | xxd -p -c 256)" sh -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