[1186] | 1 | OBS Notify Plugin
|
---|
| 2 | =================
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | Installation
|
---|
| 6 | ------------
|
---|
| 7 |
|
---|
| 8 | The file `obs_notify_generic.pm` and `obs_notify_generic_config.pm` must be located in the
|
---|
| 9 | `/usr/lib/obs/server/plugins/` directory.
|
---|
| 10 |
|
---|
| 11 | Modify the OBS config file `/usr/lib/obs/server/BSConfig.pm`
|
---|
| 12 | and add/set
|
---|
| 13 |
|
---|
| 14 | our $notification_plugin = "obs_notify_generic";
|
---|
| 15 |
|
---|
| 16 | Alternativly you can create an host specific configuration file:
|
---|
| 17 |
|
---|
| 18 | ```
|
---|
| 19 | /usr/lib/obs/server/bsconfig.`hostname -f`
|
---|
| 20 | ```
|
---|
| 21 |
|
---|
| 22 | ```
|
---|
| 23 | # notify settings
|
---|
| 24 | our $notification_plugin = "obs_notify_generic";
|
---|
| 25 |
|
---|
| 26 | 1;
|
---|
| 27 | ```
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | Configuration
|
---|
| 31 | -------------
|
---|
| 32 |
|
---|
| 33 | All configuration is done in the file
|
---|
| 34 |
|
---|
| 35 | ```
|
---|
| 36 | /usr/lib/obs/server/plugins/obs_notify_generic_config.pm
|
---|
| 37 | ```
|
---|
| 38 |
|
---|
| 39 | The default log file is
|
---|
| 40 |
|
---|
| 41 | ```
|
---|
| 42 | /src/obs/log/notify_generic.log
|
---|
| 43 | ```
|
---|
| 44 |
|
---|
| 45 | but can be configured.
|
---|
| 46 |
|
---|
| 47 | The best configuration to start is by
|
---|
| 48 |
|
---|
| 49 | ```
|
---|
| 50 | our $cfg = {
|
---|
| 51 | "UNKNOWN" => [ { "log" => 1 } ],
|
---|
| 52 | }
|
---|
| 53 | ```
|
---|
| 54 |
|
---|
| 55 | This logs all UNKNOWN events. With this configuration this are all events, as no specific events are defined.
|
---|
| 56 |
|
---|
| 57 | Usefull notification types are
|
---|
| 58 | * "BUILD_FAIL"
|
---|
| 59 | * "BUILD_SUCCESS"
|
---|
| 60 | * "REPO_PUBLISHED"
|
---|
| 61 |
|
---|
| 62 | Each event come with a number of parameter. These will also be logged.
|
---|
| 63 |
|
---|
| 64 | The configuration directove `filter` limits a notification type to certain cases. Filter can be regexes.
|
---|
| 65 |
|
---|
| 66 | Example:
|
---|
| 67 |
|
---|
| 68 | ```
|
---|
| 69 | our $cfg = {
|
---|
| 70 | "REPO_PUBLISH_STATE" => [],
|
---|
| 71 | "REPO_PUBLISHED" => [
|
---|
| 72 | {
|
---|
| 73 | "filter" => { 'project' => '.*:bareos' },
|
---|
| 74 | "log" => 1,
|
---|
| 75 | },
|
---|
| 76 | {
|
---|
| 77 | "filter" => { 'project' => '.*:bareos', 'repository' => 'SLE_12' },
|
---|
| 78 | "action" => 'logger "project $project published for repository $repository',
|
---|
| 79 | "log" => 0,
|
---|
| 80 | },
|
---|
| 81 | ],
|
---|
| 82 | "UNKNOWN" => [ { "log" => 1 } ],
|
---|
| 83 | }
|
---|
| 84 | ```
|
---|
| 85 |
|
---|
| 86 | Meaing:
|
---|
| 87 | * type=REPO_PUBLISH_STATE
|
---|
| 88 | * ignore it
|
---|
| 89 | * type=REPO_PUBLISHED:
|
---|
| 90 | * log every time a project that matches the name ":bareos" get published
|
---|
| 91 | * when the project is published for SLE_12, also create a syslog message
|
---|
| 92 |
|
---|
| 93 | Limitations:
|
---|
| 94 | * the `action` run as user obsrun. As the OBS service run as daemon, only very few environment variables are set.
|
---|
| 95 | * the `action`s should have a short runtime. As long as these scripts run, some other services from the obs are blocked. Maybe the scripts are forcefully ended by the OBS service.
|
---|