Added tags for Github builds (Fixes).

This commit is contained in:
Dmitry Khomutov 2017-04-22 21:06:53 +07:00
parent 647a5cedcd
commit 12805d58d9
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
5 changed files with 40 additions and 10 deletions

View file

@ -525,22 +525,27 @@ class WebhookController extends Controller
$builds = $this->buildStore->getByProjectAndCommit($project->getId(), $commitId);
$ignore_environments = [];
$ignore_tags = [];
if ($builds['count']) {
foreach($builds['items'] as $build) {
/** @var Build $build */
$ignore_environments[$build->getId()] = $build->getEnvironment();
$ignore_tags[$build->getId()] = $build->getTag();
}
}
$environments = $project->getEnvironmentsObjects();
if ($environments['count']) {
$created_builds = [];
$created_builds = [];
$environment_names = $project->getEnvironmentsNamesByBranch($branch);
// use base branch from project
if (!empty($environment_names)) {
$duplicates = [];
foreach ($environment_names as $environment_name) {
if (!in_array($environment_name, $ignore_environments)) {
if (
!in_array($environment_name, $ignore_environments) ||
($tag && !in_array($tag, $ignore_tags, true))
) {
// If not, create a new build job for it:
$build = $this->buildService->createBuild(
$project,
@ -575,7 +580,10 @@ class WebhookController extends Controller
}
} else {
$environment_name = null;
if (!in_array($environment_name, $ignore_environments) ||$tag) {
if (
!in_array($environment_name, $ignore_environments, true) ||
($tag && !in_array($tag, $ignore_tags, true))
) {
$build = $this->buildService->createBuild(
$project,
null,

View file

@ -720,6 +720,14 @@ class Build extends Model
return '#';
}
/**
* Get link to tag from another source (i.e. Github)
*/
public function getTagLink()
{
return '#';
}
/**
* Return a template to use to generate a link to a specific file.
*

View file

@ -32,6 +32,14 @@ class GithubBuild extends RemoteGitBuild
return 'https://github.com/' . $this->getProject()->getReference() . '/tree/' . $this->getBranch();
}
/**
* Get link to tag from another source (i.e. Github)
*/
public function getTagLink()
{
return 'https://github.com/' . $this->getProject()->getReference() . '/tree/' . $this->getTag();
}
/**
* Send status updates to any relevant third parties (i.e. Github)
*/

View file

@ -24,11 +24,13 @@
<tr>
<th><?php Lang::out('branch'); ?></th>
<td style="text-align: right">
<a target="_blank" href="<?php print $build->getBranchLink(); ?>">
<span class="label label-default"><?php print $build->getBranch(); ?></span>
<a target="_blank" href="<?= $build->getBranchLink(); ?>">
<span class="label label-default"><?= $build->getBranch(); ?></span>
</a>
<?php if ($tag = $build->getTag()): ?> /
<span class='label label-info'><?= $tag; ?></span>
<?php if ($tag = $build->getTag()): ?> /
<a target="_blank" href="<?= $build->getTagLink(); ?>">
<span class='label label-info'><?= $tag; ?></span>
</a>
<?php endif; ?>
</td>
</tr>

View file

@ -58,10 +58,14 @@ $branches = $build->getExtra('branches');
?>
</td>
<td>
<a href="<?php print $build->getBranchLink(); ?>" target="_blank"><?php print $build->getBranch(); ?></a>
<a href="<?= $build->getBranchLink(); ?>" target="_blank">
<span class='label label-default'><?= $build->getBranch(); ?></span>
</a>
<?= $branches ? ' + '.implode(', ', $branches) : ''; ?>
<?php if ($tag = $build->getTag()): ?> /
<span class='label label-info'><?= $tag; ?></span>
<?php if ($tag = $build->getTag()): ?> /
<a href="<?= $build->getTagLink(); ?>" target="_blank">
<span class='label label-info'><?= $tag; ?></span>
</a>
<?php endif; ?>
</td>
<td>