diff --git a/contrib/newrelic.php b/contrib/newrelic.php index aca0b7692..d08c0ebc4 100644 --- a/contrib/newrelic.php +++ b/contrib/newrelic.php @@ -5,6 +5,7 @@ - `newrelic_app_id` – newrelic's app id - `newrelic_api_key` – newrelic's api key - `newrelic_description` – message to send +- `newrelic_endpoint` – newrelic's REST API endpoint ## Usage @@ -31,16 +32,18 @@ return runLocally('git log -n 1 --format="%h"'); }); +set('newrelic_endpoint', 'api.newrelic.com'); + desc('Notifies New Relic of deployment'); task('newrelic:notify', function () { - if (($appId = get('newrelic_app_id')) && ($apiKey = get('newrelic_api_key'))) { + if (($appId = get('newrelic_app_id')) && ($apiKey = get('newrelic_api_key')) && ($endpoint = get('newrelic_endpoint'))) { $data = [ 'user' => get('user'), 'revision' => get('newrelic_revision'), 'description' => get('newrelic_description'), ]; - Httpie::post("https://api.newrelic.com/v2/applications/$appId/deployments.json") + Httpie::post("https://$endpoint/v2/applications/$appId/deployments.json") ->header("X-Api-Key", $apiKey) ->query(['deployment' => $data]) ->send(); diff --git a/docs/contrib/newrelic.md b/docs/contrib/newrelic.md index d375aa540..ccb9b48ef 100644 --- a/docs/contrib/newrelic.md +++ b/docs/contrib/newrelic.md @@ -17,6 +17,7 @@ require 'contrib/newrelic.php'; - `newrelic_app_id` – newrelic's app id - `newrelic_api_key` – newrelic's api key - `newrelic_description` – message to send +- `newrelic_endpoint` – newrelic's REST API endpoint ## Usage @@ -30,7 +31,7 @@ after('deploy', 'newrelic:notify'); ## Configuration ### newrelic_app_id -[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L22) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L23) :::info Required @@ -41,7 +42,7 @@ Throws exception if not set. ### newrelic_description -[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L26) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L27) @@ -51,7 +52,7 @@ return runLocally('git log -n 1 --format="%an: %s" | tr \'"\' "\'"'); ### newrelic_revision -[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L30) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L31) @@ -60,11 +61,21 @@ return runLocally('git log -n 1 --format="%h"'); ``` +### newrelic_endpoint +[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L35) + + + +```php title="Default value" +'api.newrelic.com' +``` + + ## Tasks ### newrelic:notify -[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L35) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/newrelic.php#L38) Notifies New Relic of deployment.