Commit 49f72e70 authored by Z.J. van de Weg's avatar Z.J. van de Weg

Show deployment status on a MR view

parent cbafc9ef
......@@ -37,6 +37,7 @@ v 8.11.0 (unreleased)
- Update `timeago` plugin to use multiple string/locale settings
- Remove unused images (ClemMakesApps)
- Limit git rev-list output count to one in forced push check
- Show deployment status on merge requests
- Clean up unused routes (Josef Strzibny)
- Fix issue on empty project to allow developers to only push to protected branches if given permission
- Add green outline to New Branch button. !5447 (winniehell)
......
......@@ -36,4 +36,11 @@ class Deployment < ActiveRecord::Base
def manual_actions
deployable.try(:other_actions)
end
def deployed_to(ref)
commit = project.commit(ref)
return false unless commit
project.repository.merge_base(commit.id, sha) == commit.id
end
end
......@@ -25,4 +25,10 @@ class Environment < ActiveRecord::Base
def nullify_external_url
self.external_url = nil if self.external_url.blank?
end
def deployed_to?(ref)
return unless last_deployment
last_deployment.deployed_to(ref)
end
end
......@@ -590,6 +590,12 @@ class MergeRequest < ActiveRecord::Base
!pipeline || pipeline.success?
end
def environments
target_project.environments.select do |environment|
environment.deployed_to?(ref_path)
end
end
def state_human_name
if merged?
"Merged"
......
- if @pipeline
.mr-widget-heading
- %w[success success_with_warnings skipped canceled failed running pending].each do |status|
.ci_widget{ class: "ci-#{status}", style: ("display:none" unless @pipeline.status == status) }
= ci_icon_for_status(status)
%span
CI build
= ci_label_for_status(status)
for
- commit = @merge_request.diff_head_commit
= succeed "." do
= link_to @pipeline.short_sha, namespace_project_commit_path(@merge_request.source_project.namespace, @merge_request.source_project, @pipeline.sha), class: "monospace"
%span.ci-coverage
= link_to "View details", builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), class: "js-show-tab", data: {action: 'builds'}
- @merge_request.environments.each do |environments|
- %w[success success_with_warnings skipped canceled failed running pending].each do |status|
.ci_widget{ class: "ci-#{status}", style: ("display:none" unless @pipeline.status == status) }
= ci_icon_for_status(status)
%span
CI build
= ci_label_for_status(status)
for
- commit = @merge_request.diff_head_commit
= succeed "." do
= link_to @pipeline.short_sha, namespace_project_commit_path(@merge_request.source_project.namespace, @merge_request.source_project, @pipeline.sha), class: "monospace"
%span.ci-coverage
= link_to "View details", builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), class: "js-show-tab", data: {action: 'builds'}
- elsif @merge_request.has_ci?
- # Compatibility with old CI integrations (ex jenkins) when you request status from CI server via AJAX
- # Remove in later versions when services like Jenkins will set CI status via Commit status API
// Compatibility with old CI integrations (ex jenkins) when you request status from CI server via AJAX
// Remove in later versions when services like Jenkins will set CI status via Commit status API
.mr-widget-heading
- %w[success skipped canceled failed running pending].each do |status|
.ci_widget{class: "ci-#{status}", style: "display:none"}
......@@ -42,3 +43,14 @@
.ci_widget.ci-error{style: "display:none"}
= icon("times-circle")
Could not connect to the CI server. Please check your settings and try again.
- @merge_request.environments.each do |environment|
.mr-widget-heading
.ci_widget{ class: "ci-success" }
= ci_icon_for_status("success")
%span
Released to #{environment.name}
= succeed '.' do
= time_ago_with_tooltip(environment.created_at, placement: 'bottom')
- if environment.external_url
= link_to icon('external-link'), environment.external_url
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment