Setup Gitlab for automatic builds

Webhook triggers allow you to trigger a new build by sending a request to the OpenShift API endpoint. This can be done automatically with gitlab after you have pushed code changes.

Step-by-step guide

  1. Each Build Configuration has two Trigger Urls. One for Github and the other for generic git triggers. With gitlab you have to use the generic trigger url.
    You can find the Url in your project -> browse -> builds

    triggerurls

  2. Another way to obtain the trigger url is via the commandline. Just replace test with the name of your build config. 
    user@workstation:~$ oc describe bc test
    ...
    Webhook GitHub: https://master4.tsi-af.de:8443/oapi/v1/namespaces/test/buildconfigs/test/webhooks/3bd0cf0835e4b8ed/github
    Webhook Generic: https://master4.tsi-af.de:8443/oapi/v1/namespaces/test/buildconfigs/test/webhooks/980b8feafc60d8d7/generic
    ...
  3. Now you have to set the webhook in your gitlab repository.
    You can adjust this url in your repostiroy, tab settings -> web hooks.    webhookgitlab
  4. To test your web hook either change your code and push it to the repository or use the test button in the gitlab webintefacewebhookgitlabtest
    If there aren’t any issues you the information “Hook succesfully executed” wil be shown. If you now take a look over to the
    openshift webinterface you can see the build running in a newly created pod.

    testbuild_running

Related links:

https://docs.openshift.com/enterprise/3.0/dev_guide/builds.html#webhook-triggers