Save the GitLab data in your Laravel project
GitLab push data for different objects with its webhook, this package provides the option to store that data in your database. Under the hood it use tjvb/gitlab-webhooks-receiver-for-laravel for receiving the webhook data. After storing the data it will dispatch an event that can be used to update other parts of your data or react on the new input.
You can install the package via composer:
composer require tjvb/gitlab-models-for-laravel
You can publish and run the migrations for GitLab Models for Laravel and GitLab Webhooks with:
php artisan vendor:publish --provider="TJVB\GitLabWebhooks\GitLabWebhooksServiceProvider" --tag="migrations" php artisan vendor:publish --provider="TJVB\GitlabModelsForLaravel\Providers\GitlabModelsProvider" --tag="migrations" php artisan migrate
- Set the
GITLAB_WEBHOOK_SECRETenv variable (most used version is to set it in the .env file) to have the token you use for your webhook. See https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#secret-token for more information.
- Create a webhook in GitLab.
You can create a webhook in GitLab for your project, group or system. The default url is
<application.tld>/gitlabwebhookthis can be changed in the configuration from tjvb/gitlab-webhooks-receiver-for-laravel.
- Optional configure the package.
- Listen to the events
Manual register the service provider.
If you disable the package discovery you need to add
\TJVB\GitLabWebhooks\GitLabWebhooksServiceProvider::class, to the providers array in
The package dispatched multiple events after saving the received data (a create or update) The event contains the new data.
There are a couple of env variables that can be used to change the data that shoulds be stored.
|null||The queue connection for the HookStoredListener, if not provided it will use the project default.|
|null||The queue for the HookStoredListener, if not provided it will use the project default.|
|true||That we want to store the data from the builds.|
|true||That we want to store the data from the deployments.|
|true||That we want to store the data from the issues.|
|true||That we want to store the data from the merge requests.|
|true||That we want to store the data from the notes (comments).|
|true||That we want to store the data from the pipelines.|
|true||That we want to store the data from the projects.|
|true||That we want to store the data from the tags.|
You can publish the config file with:
php artisan vendor:publish --provider="TJVB\GitlabModelsForLaravel\Providers\GitlabModelsProvider" --tag="config"
The default configuration validates the
X-Gitlab-Token in the header of the webhook request. It is possible to add multiple values in the config file or disabling the middleware to stop the verification. If you need more validation for the request (as example and i.p. filter) you can add more middleware to the configuration.
We (try to) document all the changes in CHANGELOG so read it for more information.
You are very welcome to contribute, read about it in CONTRIBUTING
If you discover any security related issues, please email firstname.lastname@example.org instead of using the issue tracker.
- GitLab for the great product, without that this package isn't needed.
The MIT License (MIT). Please see License File for more information.