Poor man's Jenkins Webhook

January 1, 2016 at 12:00am in hacks
by Roy Willemse (1 min read)

Perform an action whenever a HTTP request is received on a particular port.

Setup

sudo yum -y install nc # install netcat if you don't have it

# Fabricate a standard response
echo "\
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 12

Hello world" > response.http

echo "\
#! /bin/bash
echo 'Got request:'
cat request.http" > do-something.sh

chmod +x do-something.sh

Run

while true; do cat response.http | nc -l 1313 > request.http; ./do-something.sh; done