BigW Consortium Gitlab

environment_helper.rb 932 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
    if environment
11
      link_to environment.name, project_environment_path(project, environment)
12 13 14
    else
      content_tag :span, build.expanded_environment_name
    end
15 16
  end

Filipa Lacerda committed
17
  def deployment_link(deployment, text: nil)
18 19
    return unless deployment

Filipa Lacerda committed
20 21 22
    link_label = text ? text : "##{deployment.iid}"

    link_to link_label, [deployment.project.namespace.becomes(Namespace), deployment.project, deployment.deployable]
23 24
  end

25 26 27 28 29 30
  def last_deployment_link_for_environment_build(project, build)
    environment = environment_for_build(project, build)
    return unless environment

    deployment_link(environment.last_deployment)
  end
31
end