Webhooks with OpenShift

If you already have a third party CI/CD git-compliant pipeline established, you can easily integrate this with OpenShift using webhooks. This enables a clear north/south divide between build and deployment layers, if you so wish. Here’s Neo. This lab is another in the OpenShift MiniLabs series.



This post demonstrates the webhook technique by configuring an external git server to trigger a build event in OpenShift using webhooks. We can simulate this all on a single local workstation by concurrently running a local git service and OpenShift instance. A local tunnel is established to make the git location appear remote to the OpenShift pods/containers.



Initial Attempt

This tutorial assumes you have completed the OpenShift MiniLabs installation procedure. Then refresh before continuing.


Go Git Service

Set up a local gogs instance using postgresql on your workstation by installing the following components. Note that we can run gogs within OpenShift ( ) but this use case deliberately seeks to demonstrate an non-OpenShift instance.

Once the components are installed, make the gogs config file edit as per below. Launch the gogs service and then visit the console at http://localhost:3000 to complete standard first-time configuration settings as necessary for your postgresql database.

  • install postgresql using
  • install gogs from
$ vi ~/gogs/custom/config/app.ini
$ ./gogs web

Change cotd to local Git Repo

Create a git repo named “cotd” on the local Git server.  Bring the cloned cotd repo under local git server control.

$ cd ~/containersascode
$ rm -rf cotd
$ git clone
$ cd cotd
$ git init
$ git add .
$ git commit -am "Populate repo"
$ git remote add origin http://localhost:3000/stefanopicozzi/cotd.git
$ git push -u origin master

Set up localtunnel

Containers cannot access localhost URLs, so lets set up the localhost gogs service to respond to a local tunnel URL $LOCAL-TUNNEL . Refer for details. Note that alternative techniques to accomplish this effect, but not covered here, include 1) launching a gogs container and running gogs inside a virtual machine.

$ npm install -g localtunnel
$ lt --port 3000

OpenShift webhook

Create an application and then recover the GitHub web hook URL . Add this webhook to your gogs repo using the console at: http://localhost:3000/stefanopicozzi/cotd/settings/hooks . Use the gogs webhook “Test Delivery” feature to verify success.

$ oc login -u developer -p developer
$ oc delete project webhook
$ oc new-project webhook --display-name='Webhook Example' --description='Webhook Example'
$ oc new-app --name='cats' -l name='cats' php~https://$LOCAL-TUNNEL:3000/StefanoPicozzi/cotd.git -e SELECTOR=cats
$ oc expose service cats --name=cats -l name='cats'
$ oc describe bc cats

Trigger build/deploy

Alter the ranking of the items then trigger the webhook to fire by pushing the change to the git repo.

$ cd ~/containersascode
$ cd cotd
$ vi data/cats/rank.php
// Change ranking position
$ git add .
$ git commit -am "Changed rank"
$ git push

Verify Lab Success

Verify the new version from the Console at .

Leave a Reply