Download the PHP package dtforce/slim-hook without Composer
On this page you can find all versions of the php package dtforce/slim-hook. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dtforce/slim-hook
More information about dtforce/slim-hook
Files in dtforce/slim-hook
Package slim-hook
Short Description A Gitlab webhook using Slim Framework
License MIT
Homepage http://github.com/dtforce/slim-hook
Informations about the package slim-hook
Gitlab webhook in PHP
This is a very simple webhook for gitlab, allowing to start bash scripts as a reaction to BUILD, PUSTH and TAG events.
Installation
Install with composer:
Or by cloning this repo.
Configuration
Create a file local.yaml
in the config
folder containing something like this:
Variables
When is your script being executed, there are few variables, given to the environment.
These are examples, it should be quite clear:
Deploy
Push
Tag
Launching
You can configure Apache in the usual way, or you can launch using PHP embedded server like this:
BashREST
For convenience this application can also serve simple REST requests. This can be handy, when you want a result of the script executed on the target platform when deploying in gitlab CI. By making request to this server in the following form:
POST to /groupName/projectName/action
you will launch a script described in the config like this:
If you sent some data (in the form of JSON) in the POST body, the script will receive them in its enviroment variables in a flattened form.
Example:
sent as POST to /bash-rest/test-app/my-action
Will result in these environment variables set:
If you set-up your secret in the config script, request to the BashREST
server will need to authorize themselves with this secret. Secret is stored
in header field X-Secret
. Notice it is different to the one used by Gitlab
Webhooks.
Example of a BashREST call
Suppose config:
and assume, shell_exec
launches sh
or bash
, then call the action like this:
The response will be returned as application/text
containing result(written to stdout
)
of the executed command:
The idea is to have something like RPC for bash
over HTTP protocol.
That's all
Hope you like it!
All versions of slim-hook with dependencies
slim/slim Version ^3.1
monolog/monolog Version ^1.17
zendframework/zend-config Version ^2.6
zendframework/zend-servicemanager Version ^2.6