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

external_project.rb « content « config « chain « pipeline « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8a19e433483eae2e7aaba18ac5d311a61934532e (plain)
1
2
3
4
5
6
7
8
9
10
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
# frozen_string_literal: true

module Gitlab
  module Ci
    module Pipeline
      module Chain
        module Config
          class Content
            class ExternalProject < Source
              def content
                strong_memoize(:content) do
                  next unless external_project_path?

                  path_file, path_project = ci_config_path.split('@', 2)
                  YAML.dump('include' => [{ 'project' => path_project, 'file' => path_file }])
                end
              end

              def source
                :external_project_source
              end

              private

              # Example: path/to/.gitlab-ci.yml@another-group/another-project
              def external_project_path?
                ci_config_path =~ /\A.+(yml|yaml)@.+\z/
              end
            end
          end
        end
      end
    end
  end
end