Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
Notify New Relic only if app ID and key are set (#194)
Browse files Browse the repository at this point in the history
* Notify New Relic only if app ID and key are set

This allows setting the app ID to false when deploying to environments not monitored by New Relic. You'll still receive an error message if you don't manually override newrelic_app_id.

* Update CHANGELOG for #139
  • Loading branch information
dharkness authored and antonmedv committed Sep 15, 2018
1 parent 587d4ab commit 3054c92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
## master
[6.1.0...master](https://github.com/deployphp/recipes/compare/6.1.0...master)

### Fixed
- Fixed malformed New Relic deployment payload when ID/key falsy (#193)

## 6.1.0
[6.0.2...6.1.0](https://github.com/deployphp/recipes/compare/6.0.2...6.1.0)
Expand Down
25 changes: 12 additions & 13 deletions recipe/newrelic.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@

desc('Notifying New Relic of deployment');
task('newrelic:notify', function () {
$appId = get('newrelic_app_id');
$apiKey = get('newrelic_api_key');

$data = [
'user' => get('user'),
'revision' => get('newrelic_revision'),
'description' => get('newrelic_description'),
];

Httpie::post("https://api.newrelic.com/v2/applications/$appId/deployments.json")
->header("X-Api-Key: $apiKey")
->query(['deployment' => $data])
->send();
if (($appId = get('newrelic_app_id')) && ($apiKey = get('newrelic_api_key'))) {
$data = [
'user' => get('user'),
'revision' => get('newrelic_revision'),
'description' => get('newrelic_description'),
];

Httpie::post("https://api.newrelic.com/v2/applications/$appId/deployments.json")
->header("X-Api-Key: $apiKey")
->query(['deployment' => $data])
->send();
}
})
->once()
->shallow()
Expand Down

0 comments on commit 3054c92

Please sign in to comment.