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

View file

@ -720,6 +720,14 @@ class Build extends Model
return '#'; 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. * 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(); 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) * Send status updates to any relevant third parties (i.e. Github)
*/ */

View file

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

View file

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