Fixed error with Github commit status.
This commit is contained in:
parent
daac392dd7
commit
b95992b005
2 changed files with 19 additions and 12 deletions
|
|
@ -44,7 +44,7 @@ class BitbucketBuild extends RemoteGitBuild
|
|||
/**
|
||||
* Send status updates to any relevant third parties (i.e. Bitbucket)
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function sendStatusPostback()
|
||||
{
|
||||
|
|
@ -95,7 +95,7 @@ class BitbucketBuild extends RemoteGitBuild
|
|||
|
||||
$phpCensorUrl = Config::getInstance()->get('php-censor.url');
|
||||
|
||||
$url = sprintf(
|
||||
$url = sprintf(
|
||||
'/2.0/repositories/%s/commit/%s/statuses/build',
|
||||
$this->getExtra('build_type') == 'pull_request'
|
||||
? $this->getExtra('remote_reference')
|
||||
|
|
@ -104,15 +104,15 @@ class BitbucketBuild extends RemoteGitBuild
|
|||
);
|
||||
|
||||
$client = new Client([
|
||||
'base_uri' => 'https://api.bitbucket.org',
|
||||
'base_uri' => 'https://api.bitbucket.org',
|
||||
'http_errors' => false,
|
||||
]);
|
||||
$response = $client->post($url, [
|
||||
'auth' => [$username, $appPassword],
|
||||
'headers' => [
|
||||
'auth' => [$username, $appPassword],
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
'json' => [
|
||||
'json' => [
|
||||
'state' => $status,
|
||||
'key' => 'PHP-CENSOR',
|
||||
'url' => $phpCensorUrl . '/build/view/' . $this->getId(),
|
||||
|
|
|
|||
|
|
@ -42,8 +42,10 @@ class GithubBuild extends RemoteGitBuild
|
|||
}
|
||||
|
||||
/**
|
||||
* Send status updates to any relevant third parties (i.e. Github)
|
||||
*/
|
||||
* Send status updates to any relevant third parties (i.e. Github)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function sendStatusPostback()
|
||||
{
|
||||
if (!in_array($this->getSource(), [Build::SOURCE_WEBHOOK, Build::SOURCE_WEBHOOK_PULL_REQUEST], true)) {
|
||||
|
|
@ -91,9 +93,12 @@ class GithubBuild extends RemoteGitBuild
|
|||
|
||||
$phpCensorUrl = Config::getInstance()->get('php-censor.url');
|
||||
|
||||
$url = 'https://api.github.com/repos/' . $project->getReference() . '/statuses/' . $this->getCommitId();
|
||||
$client = new Client();
|
||||
$client->post($url, [
|
||||
$url = '/repos/' . $project->getReference() . '/statuses/' . $this->getCommitId();
|
||||
$client = new Client([
|
||||
'base_uri' => 'https://api.github.com',
|
||||
'http_errors' => false,
|
||||
]);
|
||||
$response = $client->post($url, [
|
||||
'headers' => [
|
||||
'Authorization' => 'token ' . $token,
|
||||
'Content-Type' => 'application/x-www-form-urlencoded'
|
||||
|
|
@ -106,7 +111,9 @@ class GithubBuild extends RemoteGitBuild
|
|||
]
|
||||
]);
|
||||
|
||||
return true;
|
||||
$status = (integer)$response->getStatusCode();
|
||||
|
||||
return ($status >= 200 && $status < 300);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue