Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-11-04 18:35:22 +0300
committerAnnabel Dunstone Gray <annabel.dunstone@gmail.com>2016-11-09 01:50:03 +0300
commitc70acb57f5adcd4f0a19f8e7d5bcb356464a9c64 (patch)
tree42d3d2c4d8cfabb29c3144ff2a17591dc5f16d2b /app/helpers/environment_helper.rb
parent73467bd1634898632d1c9c4e5879546ec9f53032 (diff)
Expose `last_deployment` on `Ci::Builds` [ci skip]
Diffstat (limited to 'app/helpers/environment_helper.rb')
-rw-r--r--app/helpers/environment_helper.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/helpers/environment_helper.rb b/app/helpers/environment_helper.rb
new file mode 100644
index 00000000000..1e2a8c7ddbd
--- /dev/null
+++ b/app/helpers/environment_helper.rb
@@ -0,0 +1,21 @@
+module EnvironmentHelper
+ def environment_for_build(project, build)
+ return unless build.environment
+
+ environment_name = ExpandVariables.expand(build.environment, build.variables)
+ project.environments.find_by(name: environment_name)
+ end
+
+ def environment_link_for_build(project, build)
+ environment = environment_for_build(project, build)
+ return unless environment
+
+ link_to environment.name, namespace_project_environment_path(project.namespace, project, environment)
+ end
+
+ def deployment_link(project, deployment)
+ return unless deployment
+
+ link_to "##{deployment.id}", [deployment.project.namespace.becomes(Namespace), deployment.project, deployment.deployable]
+ end
+end