mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-25 01:33:10 +01:00
224 lines
4.4 KiB
Markdown
224 lines
4.4 KiB
Markdown
<!-- DO NOT EDIT THIS FILE! -->
|
||
<!-- Instead edit contrib/cimonitor.php -->
|
||
<!-- Then run bin/docgen -->
|
||
|
||
# Cimonitor Recipe
|
||
|
||
```php
|
||
require 'contrib/cimonitor.php';
|
||
```
|
||
|
||
[Source](/contrib/cimonitor.php)
|
||
|
||
|
||
|
||
Monitor your deployments on [CIMonitor](https://github.com/CIMonitor/CIMonitor).
|
||
|
||

|
||
|
||
|
||
Add tasks on deploy:
|
||
|
||
```php
|
||
before('deploy', 'cimonitor:notify');
|
||
after('deploy:success', 'cimonitor:notify:success');
|
||
after('deploy:failed', 'cimonitor:notify:failure');
|
||
```
|
||
|
||
## Configuration
|
||
|
||
- `cimonitor_webhook` – CIMonitor server webhook url, **required**
|
||
```
|
||
set('cimonitor_webhook', 'https://cimonitor.enrise.com/webhook/deployer');
|
||
```
|
||
- `cimonitor_title` – the title of application, default the username\reponame combination from `{{repository}}`
|
||
```
|
||
set('cimonitor_title', '');
|
||
```
|
||
- `cimonitor_user` – User object with name and email, default gets information from `git config`
|
||
```
|
||
set('cimonitor_user', function () {
|
||
return [
|
||
'name' => 'John Doe',
|
||
'email' => 'john@enrise.com',
|
||
];
|
||
});
|
||
```
|
||
|
||
Various cimonitor statusses are set, in case you want to change these yourselves. See the [CIMonitor documentation](https://cimonitor.readthedocs.io/en/latest/) for the usages of different states.
|
||
|
||
## Usage
|
||
|
||
If you want to notify only about beginning of deployment add this line only:
|
||
|
||
```php
|
||
before('deploy', 'cimonitor:notify');
|
||
```
|
||
|
||
If you want to notify about successful end of deployment add this too:
|
||
|
||
```php
|
||
after('deploy:success', 'cimonitor:notify:success');
|
||
```
|
||
|
||
If you want to notify about failed deployment add this too:
|
||
|
||
```php
|
||
after('deploy:failed', 'cimonitor:notify:failure');
|
||
```
|
||
|
||
|
||
## Configuration
|
||
### cimonitor_title
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L63)
|
||
|
||
Title of project based on git repo
|
||
|
||
```php title="Default value"
|
||
$repo = get('repository');
|
||
$pattern = '/\w+\/\w+/';
|
||
return preg_match($pattern, $repo, $titles) ? $titles[0] : $repo;
|
||
```
|
||
|
||
|
||
### cimonitor_user
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L68)
|
||
|
||
|
||
|
||
```php title="Default value"
|
||
return [
|
||
'name' => runLocally('git config --get user.name'),
|
||
'email' => runLocally('git config --get user.email'),
|
||
];
|
||
```
|
||
|
||
|
||
### cimonitor_status_info
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L76)
|
||
|
||
CI monitor status states and job states
|
||
|
||
```php title="Default value"
|
||
'info'
|
||
```
|
||
|
||
|
||
### cimonitor_status_warning
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L77)
|
||
|
||
|
||
|
||
```php title="Default value"
|
||
'warning'
|
||
```
|
||
|
||
|
||
### cimonitor_status_error
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L78)
|
||
|
||
|
||
|
||
```php title="Default value"
|
||
'error'
|
||
```
|
||
|
||
|
||
### cimonitor_status_success
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L79)
|
||
|
||
|
||
|
||
```php title="Default value"
|
||
'success'
|
||
```
|
||
|
||
|
||
### cimonitor_job_state_info
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L80)
|
||
|
||
|
||
|
||
```php title="Default value"
|
||
get('cimonitor_status_info')
|
||
```
|
||
|
||
|
||
### cimonitor_job_state_pending
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L81)
|
||
|
||
|
||
|
||
```php title="Default value"
|
||
'pending'
|
||
```
|
||
|
||
|
||
### cimonitor_job_state_running
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L82)
|
||
|
||
|
||
|
||
```php title="Default value"
|
||
'running'
|
||
```
|
||
|
||
|
||
### cimonitor_job_state_warning
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L83)
|
||
|
||
|
||
|
||
```php title="Default value"
|
||
get('cimonitor_status_warning')
|
||
```
|
||
|
||
|
||
### cimonitor_job_state_error
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L84)
|
||
|
||
|
||
|
||
```php title="Default value"
|
||
get('cimonitor_status_error')
|
||
```
|
||
|
||
|
||
### cimonitor_job_state_success
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L85)
|
||
|
||
|
||
|
||
```php title="Default value"
|
||
get('cimonitor_status_success')
|
||
```
|
||
|
||
|
||
|
||
## Tasks
|
||
|
||
### cimonitor:notify
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L88)
|
||
|
||
Notifies CIMonitor.
|
||
|
||
|
||
|
||
|
||
### cimonitor:notify:success
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L114)
|
||
|
||
Notifies CIMonitor about deploy finish.
|
||
|
||
|
||
|
||
|
||
### cimonitor:notify:failure
|
||
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L142)
|
||
|
||
Notifies CIMonitor about deploy failure.
|
||
|
||
|
||
|
||
|