{"_id":"590a04f4ed80861900cbc769","project":"55b2d5baa74a380d00e290c4","user":"55b2d5626862a10d00887af9","category":{"_id":"590a04f3ed80861900cbc73e","project":"55b2d5baa74a380d00e290c4","version":"590a04f2ed80861900cbc737","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-11-14T01:14:16.514Z","from_sync":false,"order":6,"slug":"webhooks","title":"Webhooks"},"parentDoc":null,"__v":0,"version":{"_id":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","__v":4,"createdAt":"2017-05-03T16:27:30.085Z","releaseDate":"2017-05-03T16:27:30.085Z","categories":["590a04f3ed80861900cbc738","590a04f3ed80861900cbc739","590a04f3ed80861900cbc73a","590a04f3ed80861900cbc73b","590a04f3ed80861900cbc73c","590a04f3ed80861900cbc73d","590a04f3ed80861900cbc73e","590a04f3ed80861900cbc73f","590a04f3ed80861900cbc740","590a04f3ed80861900cbc741","590a04f3ed80861900cbc742","590a04f3ed80861900cbc743","590a04f3ed80861900cbc744","590a04f3ed80861900cbc745","590a04f3ed80861900cbc746","590a04f3ed80861900cbc747","590a04f3ed80861900cbc748","590a04f3ed80861900cbc749","590a04f3ed80861900cbc74a","590a04f3ed80861900cbc74b","590a04f3ed80861900cbc74c","590a04f3ed80861900cbc74d","59124949de13f61900336a7a","5914b04e7c2c552d008b7104","5914b47242c6a22300b9dc20"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"7.0.0","version":"7"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-03-30T23:27:28.888Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"A webhook notifies buddybuild of code changes you make to your repo. Whenever a new change is pushed to Gitolite, buddybuild will automatically kick off a new build - ensuring you have up-to-date build status and your testers have the very latest builds.\n\nSince Gitolite core does not have webhook functionality by default, we describe how to extend Gitolite to provide this functionality using the git post-receive script called [notify-webhook](https://github.com/metajack/notify-webhook).\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Only a Gitolite admin user can add a Gitolite webhook\"\n}\n[/block]\n## Step 1: Copy the webhook url from buddybuild\nOn the Builds page, in the red banner at the top of the page, click on **Resolve this issue.**\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/feaf53d-Webhooks_-_resolve_banner.png\",\n        \"Webhooks - resolve banner.png\",\n        1500,\n        298,\n        \"#f8403f\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nIn the dialog box that appears, **select and copy the webhook URL.** This URL is specific to your app and will be used to identify your app when sending webhooks from Gitolite.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ca94b33-Webhooks_-_modal.png\",\n        \"Webhooks - modal.png\",\n        1500,\n        838,\n        \"#535663\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"notify-webhook requires python3 and simplejson\",\n  \"body\": \"For more information see https://github.com/metajack/notify-webhook\"\n}\n[/block]\n## Step 2: Enable repo-specific-hooks, site-local gitolite code and whitelist notify-webhook keys\nIn this section we will be following the [Gitolite documentation](http://gitolite.com/gitolite/cookbook.html#v3.6-variation-repo-specific-hooks) to enable repository-specific webhooks, if not already enabled.\n\nOn the Gitolite server modify the`.gitolite.rc` file as follows:\n* To enable `repo-specific-hooks` uncomment the `repo-specific-hooks` line in the rc file or add it to the `ENABLE` list if it doesn't exist.\n* To enable site-local gitolite code add this line in the rc file, within the `%RC` block, if it's not already present, or uncomment it if it's already present and commented out:\n```LOCAL_CODE => \"$rc{GL_ADMIN_BASE}/local\",```\n* To whitelist the notify-webhook keys modify the `GIT_CONFIG_KEYS` to include `hooks.webhookurl`:\n```GIT_CONFIG_KEYS => 'hooks\\.webhookurl',```\n\nThen call `gitolite setup` to apply the changes on the Gitolite server.\n\n## Step 3: Install a git post-receive hook script\n[notify-webhook](https://github.com/metajack/notify-webhook) is a git post-receive hook script that posts JSON data to a webhook capable service like buddybuild. Download and install the webhook as follows on a local Gitolite admin machine:\n```\nwget https://raw.githubusercontent.com/metajack/notify-webhook/master/notify-webhook.py\n\nmv notify-webhook.py gitolite-admin/local/hooks/repo-specific/notify-webhook\n\ngit add gitolite-admin/local/hooks/repo-specific/notify-webhook\n```\n\n## Step 4: Configure the post-receive webhook\nModify your `gitolite-admin/conf/gitolite.conf` file to register the git post-receive hook named `notify-webhook`. Then configure the buddybuild webhook URL that you copied from Step 1. The configuration for your repository should look like this:\n```\nrepo my-ios-app\n  option hook.post-receive = notify-webhook\n  config hooks.webhookurl = \"https://dashboard.buddybuild.com/api/webhook?appID=56fc8d0f9bdbfe01008b4f2c\"\n```\nCommit and push the local Gitolite configuration changes to apply the settings. The next time you push code to your repository buddybuild will automatically build your app. Welcome to mobile continuous integration!","excerpt":"","slug":"adding-a-gitolite-webhook","type":"basic","title":"Adding a Gitolite Webhook"}

Adding a Gitolite Webhook


A webhook notifies buddybuild of code changes you make to your repo. Whenever a new change is pushed to Gitolite, buddybuild will automatically kick off a new build - ensuring you have up-to-date build status and your testers have the very latest builds. Since Gitolite core does not have webhook functionality by default, we describe how to extend Gitolite to provide this functionality using the git post-receive script called [notify-webhook](https://github.com/metajack/notify-webhook). [block:callout] { "type": "info", "title": "Only a Gitolite admin user can add a Gitolite webhook" } [/block] ## Step 1: Copy the webhook url from buddybuild On the Builds page, in the red banner at the top of the page, click on **Resolve this issue.** [block:image] { "images": [ { "image": [ "https://files.readme.io/feaf53d-Webhooks_-_resolve_banner.png", "Webhooks - resolve banner.png", 1500, 298, "#f8403f" ], "sizing": "full" } ] } [/block] In the dialog box that appears, **select and copy the webhook URL.** This URL is specific to your app and will be used to identify your app when sending webhooks from Gitolite. [block:image] { "images": [ { "image": [ "https://files.readme.io/ca94b33-Webhooks_-_modal.png", "Webhooks - modal.png", 1500, 838, "#535663" ] } ] } [/block] [block:callout] { "type": "info", "title": "notify-webhook requires python3 and simplejson", "body": "For more information see https://github.com/metajack/notify-webhook" } [/block] ## Step 2: Enable repo-specific-hooks, site-local gitolite code and whitelist notify-webhook keys In this section we will be following the [Gitolite documentation](http://gitolite.com/gitolite/cookbook.html#v3.6-variation-repo-specific-hooks) to enable repository-specific webhooks, if not already enabled. On the Gitolite server modify the`.gitolite.rc` file as follows: * To enable `repo-specific-hooks` uncomment the `repo-specific-hooks` line in the rc file or add it to the `ENABLE` list if it doesn't exist. * To enable site-local gitolite code add this line in the rc file, within the `%RC` block, if it's not already present, or uncomment it if it's already present and commented out: ```LOCAL_CODE => "$rc{GL_ADMIN_BASE}/local",``` * To whitelist the notify-webhook keys modify the `GIT_CONFIG_KEYS` to include `hooks.webhookurl`: ```GIT_CONFIG_KEYS => 'hooks\.webhookurl',``` Then call `gitolite setup` to apply the changes on the Gitolite server. ## Step 3: Install a git post-receive hook script [notify-webhook](https://github.com/metajack/notify-webhook) is a git post-receive hook script that posts JSON data to a webhook capable service like buddybuild. Download and install the webhook as follows on a local Gitolite admin machine: ``` wget https://raw.githubusercontent.com/metajack/notify-webhook/master/notify-webhook.py mv notify-webhook.py gitolite-admin/local/hooks/repo-specific/notify-webhook git add gitolite-admin/local/hooks/repo-specific/notify-webhook ``` ## Step 4: Configure the post-receive webhook Modify your `gitolite-admin/conf/gitolite.conf` file to register the git post-receive hook named `notify-webhook`. Then configure the buddybuild webhook URL that you copied from Step 1. The configuration for your repository should look like this: ``` repo my-ios-app option hook.post-receive = notify-webhook config hooks.webhookurl = "https://dashboard.buddybuild.com/api/webhook?appID=56fc8d0f9bdbfe01008b4f2c" ``` Commit and push the local Gitolite configuration changes to apply the settings. The next time you push code to your repository buddybuild will automatically build your app. Welcome to mobile continuous integration!