Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rebuild on Git webhook #1346

Merged
merged 1 commit into from Jun 18, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+15 −10
Diff settings

Always

Just for now

@@ -178,8 +178,9 @@ public function git($projectId)
$commit = $this->getParam('commit');
$commitMessage = $this->getParam('message');
$committer = $this->getParam('committer');
$rebuild = $this->getParam('rebuild') ?? false;
return $this->createBuild($project, $commit, $branch, $committer, $commitMessage);
return $this->createBuild($project, $commit, $branch, $committer, $commitMessage, $rebuild);
}
/**
@@ -325,7 +326,7 @@ protected function githubPullRequest(Project $project, array $payload)
'remote_url' => $payload['pull_request']['head']['repo'][$remoteUrlKey],
);
$results[$id] = $this->createBuild($project, $id, $branch, $committer, $message, $extra);
$results[$id] = $this->createBuild($project, $id, $branch, $committer, $message, false, $extra);
$status = 'ok';
} catch (Exception $ex) {
$results[$id] = array('status' => 'failed', 'error' => $ex->getMessage());
@@ -411,6 +412,7 @@ public function svn($projectId)
* @param string $branch
* @param string $committer
* @param string $commitMessage
* @param bool $rebuild
* @param array $extra
*
* @return array
@@ -423,16 +425,19 @@ protected function createBuild(
$branch,
$committer,
$commitMessage,
bool $rebuild = false,
array $extra = null
) {
// Check if a build already exists for this commit ID:
$builds = $this->buildStore->getByProjectAndCommit($project->getId(), $commitId);
if ($builds['count']) {
return array(
'status' => 'ignored',
'message' => sprintf('Duplicate of build #%d', $builds['items'][0]->getId())
);
// 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:
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.