Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions contrib/ms-teams.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
return get('application', 'Project');
});

// Allow Continue on Failure
set('teams_failure_continue', false);

// Deploy message
set('teams_text', '_{{user}}_ deploying `{{what}}` to *{{where}}*');
set('teams_success_text', 'Deploy to *{{where}}* successful');
Expand All @@ -97,10 +100,19 @@
return;
}

Httpie::post(get('teams_webhook'))->jsonBody([
"themeColor" => get('teams_color'),
'text' => get('teams_text'),
])->send();
try {
Httpie::post(get('teams_webhook'))->jsonBody([
"themeColor" => get('teams_color'),
'text' => get('teams_text'),
])->send();
} catch (\Exception $e) {
if (get('teams_failure_continue', false)) {
warning('Error sending Teams Notification: ' . $e->getMessage());
} else {
throw $e;
}
}

})
->once()
->hidden();
Expand All @@ -112,10 +124,18 @@
return;
}

Httpie::post(get('teams_webhook'))->jsonBody([
"themeColor" => get('teams_success_color'),
'text' => get('teams_success_text'),
])->send();
try {
Httpie::post(get('teams_webhook'))->jsonBody([
"themeColor" => get('teams_success_color'),
'text' => get('teams_success_text'),
])->send();
} catch (\Exception $e) {
if (get('teams_failure_continue', false)) {
warning('Error sending Teams Notification: ' . $e->getMessage());
} else {
throw $e;
}
}
})
->once()
->hidden();
Expand All @@ -127,10 +147,18 @@
return;
}

Httpie::post(get('teams_webhook'))->jsonBody([
"themeColor" => get('teams_failure_color'),
'text' => get('teams_failure_text'),
])->send();
try {
Httpie::post(get('teams_webhook'))->jsonBody([
"themeColor" => get('teams_failure_color'),
'text' => get('teams_failure_text'),
])->send();
} catch (\Exception $e) {
if (get('teams_failure_continue', false)) {
warning('Error sending Teams Notification: ' . $e->getMessage());
} else {
throw $e;
}
}
})
->once()
->hidden();
14 changes: 14 additions & 0 deletions docs/contrib/ms-teams.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ after('deploy:failed', 'teams:notify:failure');
set('teams_webhook', 'https://outlook.office.com/webhook/...');
```
- `teams_title` – the title of application, default `{{application}}`
- `teams_failure_continue` - allow deploys to continue on failure
```
set('teams_failure_continue', true);
```
- `teams_text` – notification message template, markdown supported
```
set('teams_text', '_{{user}}_ deploying `{{what}}` to *{{where}}*');
Expand All @@ -56,6 +60,7 @@ after('deploy:failed', 'teams:notify:failure');
- `teams_color` – color's attachment
- `teams_success_color` – success color's attachment
- `teams_failure_color` – failure color's attachment

## Usage
If you want to notify only about beginning of deployment add this line only:
```php
Expand All @@ -81,6 +86,15 @@ Title of project
return get('application', 'Project');
```

### teams_failure_continue
[Source](https://github.com/deployphp/deployer/blob/master/contrib/ms-teams.php#L79)

Allow Continue on Failure

```php title="Continue on Failure"
return get('teams_failure_continue', false)
```


### teams_text
[Source](https://github.com/deployphp/deployer/blob/master/contrib/ms-teams.php#L84)
Expand Down
Loading