Module: Ci::PipelinesHelper

Includes:
Gitlab::Ci::Warnings
Defined in:
app/helpers/ci/pipelines_helper.rb

Constant Summary

Constants included from Gitlab::Ci::Warnings

Gitlab::Ci::Warnings::MAX_LIMIT

Instance Method Summary collapse

Instance Method Details

#has_gitlab_ci?(project) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'app/helpers/ci/pipelines_helper.rb', line 7

def has_gitlab_ci?(project)
  project.has_ci? && project.builds_enabled?
end

#new_pipeline_data(project) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'app/helpers/ci/pipelines_helper.rb', line 84

def new_pipeline_data(project)
  {
    project_id: project.id,
    pipelines_path: project_pipelines_path(project),
    default_branch: project.default_branch,
    pipeline_editor_path: project_ci_pipeline_editor_path(project),
    can_view_pipeline_editor: can_view_pipeline_editor?(project).to_s,
    ref_param: params[:ref] || project.default_branch,
    var_param: params[:var].to_json,
    file_param: params[:file_var].to_json,
    project_path: project.full_path,
    project_refs_endpoint: refs_project_path(project, sort: 'updated_desc'),
    settings_link: project_settings_ci_cd_path(project),
    max_warnings: ::Gitlab::Ci::Warnings::MAX_LIMIT,
    user_role: project.team.human_max_access(current_user&.id),
    can_set_pipeline_variables: Ability.allowed?(current_user, :set_pipeline_variables, project).to_s
  }
end

#pipelines_list_data(project, list_url) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/helpers/ci/pipelines_helper.rb', line 50

def pipelines_list_data(project, list_url)
  artifacts_endpoint_placeholder = ':pipeline_artifacts_id'

  {
    endpoint: list_url,
    project_id: project.id,
    default_branch_name: project.default_branch,
    params: params.to_json,
    artifacts_endpoint: downloadable_artifacts_project_pipeline_path(project, artifacts_endpoint_placeholder,
      format: :json),
    artifacts_endpoint_placeholder: artifacts_endpoint_placeholder,
    pipeline_schedules_path: pipeline_schedules_path(project),
    can_create_pipeline: can?(current_user, :create_pipeline, project).to_s,
    new_pipeline_path: can?(current_user, :create_pipeline, project) && new_project_pipeline_path(project),
    reset_cache_path: can_any?(current_user, [:admin_pipeline, :admin_runners],
      project) && reset_cache_project_settings_ci_cd_path(project),
    has_gitlab_ci: has_gitlab_ci?(project).to_s,
    pipeline_editor_path: can?(current_user, :create_pipeline, project) && project_ci_pipeline_editor_path(project),
    suggested_ci_templates: suggested_ci_templates.to_json,
    full_path: project.full_path,
    visibility_pipeline_id_type: visibility_pipeline_id_type,
    show_jenkins_ci_prompt: show_jenkins_ci_prompt(project).to_s,
    pipelines_analytics_path: charts_project_pipelines_path(project),
    uses_external_config: uses_external_config?(project).to_s,
    empty_state_illustration_path: image_path('illustrations/empty-state/empty-pipeline-md.svg')
  }
end

#suggested_ci_templatesObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/helpers/ci/pipelines_helper.rb', line 11

def suggested_ci_templates
  [
    { name: 'Android', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/android.svg') },
    { name: 'Bash', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/bash.svg') },
    { name: 'C++', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/c_plus_plus.svg') },
    { name: 'Clojure', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/clojure.svg') },
    { name: 'Composer', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/composer.svg') },
    { name: 'Crystal', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/crystal.svg') },
    { name: 'Dart', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/dart.svg') },
    { name: 'Django', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/django.svg') },
    { name: 'Docker', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/docker.png') },
    { name: 'Elixir', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/elixir.svg') },
    { name: 'iOS-Fastlane', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/fastlane.svg'),
      title: 'iOS with Fastlane' },
    { name: 'Flutter', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/flutter.svg') },
    { name: 'Go', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/go_logo.svg') },
    { name: 'Gradle', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/gradle.svg') },
    { name: 'Grails', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/grails.svg') },
    { name: 'dotNET', logo: image_path('illustrations/third-party-logos/dotnet.svg') },
    { name: 'Julia', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/julia.svg') },
    { name: 'Laravel', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/laravel.svg') },
    { name: 'LaTeX', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/latex.svg') },
    { name: 'MATLAB', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/matlab.svg') },
    { name: 'Maven', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/maven.svg') },
    { name: 'Mono', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/mono.svg') },
    { name: 'Nodejs', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/node_js.svg') },
    { name: 'npm', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/npm.svg') },
    { name: 'OpenShift', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/openshift.svg') },
    { name: 'Packer', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/packer.svg') },
    { name: 'PHP', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/php.svg') },
    { name: 'Python', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/python.svg') },
    { name: 'Ruby', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/ruby.svg') },
    { name: 'Rust', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/rust.svg') },
    { name: 'Scala', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/scala.svg') },
    { name: 'Swift', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/swift.svg') },
    { name: 'Terraform', logo: image_path('illustrations/third-party-logos/ci_cd-template-logos/terraform.svg') }
  ]
end

#uses_external_config?(project) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
# File 'app/helpers/ci/pipelines_helper.rb', line 103

def uses_external_config?(project)
  Gitlab::Ci::ProjectConfig.new(project: project, sha: nil).external?
end

#visibility_pipeline_id_typeObject



78
79
80
81
82
# File 'app/helpers/ci/pipelines_helper.rb', line 78

def visibility_pipeline_id_type
  return 'id' unless current_user.present?

  current_user.user_preference.visibility_pipeline_id_type
end