BigW Consortium Gitlab

environment_helper.rb 907 Bytes
Newer Older
1 2 3 4
module EnvironmentHelper
  def environment_for_build(project, build)
    return unless build.environment

5
    project.environments.find_by(name: build.expanded_environment_name)
6 7 8 9
  end

  def environment_link_for_build(project, build)
    environment = environment_for_build(project, build)
10 11 12 13 14
    if environment
      link_to environment.name, namespace_project_environment_path(project.namespace, project, environment)
    else
      content_tag :span, build.expanded_environment_name
    end
15 16
  end

17
  def deployment_link(deployment)
18 19
    return unless deployment

20
    link_to "##{deployment.iid}", [deployment.project.namespace.becomes(Namespace), deployment.project, deployment.deployable]
21
  end
22 23 24 25 26 27 28

  def last_deployment_link_for_environment_build(project, build)
    environment = environment_for_build(project, build)
    return unless environment

    deployment_link(environment.last_deployment)
  end
29
end