protected function createBuild(
        Project $project,
        $commitId,
        $branch,
        $committer,
        $commitMessage,
        bool $rebuild = false,
        array $extra = null
    ) {
        // Check if a build already exists for this commit ID when not rebuilding:
        if (!$rebuild) {
            $builds = $this->buildStore->getByProjectAndCommit($project->getId(), $commitId);

            if ($builds['count']) {
                return array(
                    'status' => 'ignored',
                    'message' => sprintf('Duplicate of build #%d', $builds['items'][0]->getId())
                );
            }
        }

        // If not, create a new build job for it:
        $build = $this->buildService->createBuild($project, $commitId, $branch, $committer, $commitMessage, $extra);

        return array('status' => 'ok', 'buildID' => $build->getID());
    }