public function bitbucket($projectId)
    {
        $project = $this->fetchProject($projectId, 'bitbucket');
    
        // Support both old services and new webhooks
        if ($payload = $this->getParam('payload')) {
            return $this->bitbucketService(json_decode($payload, true), $project);
        }

        $payload = json_decode(file_get_contents("php://input"), true);

        if (empty($payload['push']['changes'])) {
            // Invalid event from bitbucket
            return [
                'status' => 'failed',
                'commits' => []
            ];
        }

        return $this->bitbucketWebhook($payload, $project);
    }