2016-11-04 11:35:22 -04:00
|
|
|
module EnvironmentHelper
|
|
|
|
def environment_for_build(project, build)
|
|
|
|
return unless build.environment
|
|
|
|
|
2016-11-16 18:23:05 -05:00
|
|
|
project.environments.find_by(name: build.expanded_environment_name)
|
2016-11-04 11:35:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def environment_link_for_build(project, build)
|
|
|
|
environment = environment_for_build(project, build)
|
2016-11-16 18:23:05 -05:00
|
|
|
if environment
|
2017-06-29 13:06:35 -04:00
|
|
|
link_to environment.name, project_environment_path(project, environment)
|
2016-11-16 18:23:05 -05:00
|
|
|
else
|
|
|
|
content_tag :span, build.expanded_environment_name
|
|
|
|
end
|
2016-11-04 11:35:22 -04:00
|
|
|
end
|
|
|
|
|
2016-12-07 10:27:22 -05:00
|
|
|
def deployment_link(deployment, text: nil)
|
2016-11-04 11:35:22 -04:00
|
|
|
return unless deployment
|
|
|
|
|
2016-12-07 10:27:22 -05:00
|
|
|
link_label = text ? text : "##{deployment.iid}"
|
|
|
|
|
|
|
|
link_to link_label, [deployment.project.namespace.becomes(Namespace), deployment.project, deployment.deployable]
|
2016-11-30 06:57:38 -05:00
|
|
|
end
|
|
|
|
|
2016-11-16 18:23:05 -05:00
|
|
|
def last_deployment_link_for_environment_build(project, build)
|
|
|
|
environment = environment_for_build(project, build)
|
|
|
|
return unless environment
|
|
|
|
|
|
|
|
deployment_link(environment.last_deployment)
|
|
|
|
end
|
2016-11-04 11:35:22 -04:00
|
|
|
end
|