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

Commit 3054c92

Browse files
dharknessantonmedv
authored andcommitted
Notify New Relic only if app ID and key are set (#194)
* 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
1 parent 587d4ab commit 3054c92

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
## master
55
[6.1.0...master](https://github.com/deployphp/recipes/compare/6.1.0...master)
66

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

810
## 6.1.0
911
[6.0.2...6.1.0](https://github.com/deployphp/recipes/compare/6.0.2...6.1.0)

recipe/newrelic.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,18 @@
2323

2424
desc('Notifying New Relic of deployment');
2525
task('newrelic:notify', function () {
26-
$appId = get('newrelic_app_id');
27-
$apiKey = get('newrelic_api_key');
28-
29-
$data = [
30-
'user' => get('user'),
31-
'revision' => get('newrelic_revision'),
32-
'description' => get('newrelic_description'),
33-
];
34-
35-
Httpie::post("https://api.newrelic.com/v2/applications/$appId/deployments.json")
36-
->header("X-Api-Key: $apiKey")
37-
->query(['deployment' => $data])
38-
->send();
26+
if (($appId = get('newrelic_app_id')) && ($apiKey = get('newrelic_api_key'))) {
27+
$data = [
28+
'user' => get('user'),
29+
'revision' => get('newrelic_revision'),
30+
'description' => get('newrelic_description'),
31+
];
32+
33+
Httpie::post("https://api.newrelic.com/v2/applications/$appId/deployments.json")
34+
->header("X-Api-Key: $apiKey")
35+
->query(['deployment' => $data])
36+
->send();
37+
}
3938
})
4039
->once()
4140
->shallow()

0 commit comments

Comments
 (0)