2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
module Gitlab
|
|
|
|
module Template
|
2016-09-13 17:45:13 +05:30
|
|
|
class GitlabCiYmlTemplate < BaseTemplate
|
2021-01-03 14:25:43 +05:30
|
|
|
BASE_EXCLUDED_PATTERNS = [%r{\.latest\.}].freeze
|
2022-07-16 23:28:13 +05:30
|
|
|
BASE_DIR = 'lib/gitlab/ci/templates'
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
def description
|
|
|
|
"# This file is a template, and might need editing before it works on your project."
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
class << self
|
2021-09-04 01:27:46 +05:30
|
|
|
extend ::Gitlab::Utils::Override
|
2020-11-24 15:15:51 +05:30
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
def extension
|
|
|
|
'.gitlab-ci.yml'
|
|
|
|
end
|
|
|
|
|
|
|
|
def categories
|
|
|
|
{
|
2017-08-17 22:00:37 +05:30
|
|
|
'General' => '',
|
|
|
|
'Pages' => 'Pages',
|
2020-04-08 14:13:33 +05:30
|
|
|
'Verify' => 'Verify',
|
2017-08-17 22:00:37 +05:30
|
|
|
'Auto deploy' => 'autodeploy'
|
2016-06-22 15:30:34 +05:30
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
def include_categories_for_file
|
|
|
|
{
|
|
|
|
"SAST#{self.extension}" => { 'Security' => 'Security' }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
def excluded_patterns
|
|
|
|
strong_memoize(:excluded_patterns) do
|
|
|
|
BASE_EXCLUDED_PATTERNS + additional_excluded_patterns
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def additional_excluded_patterns
|
|
|
|
[%r{Verify/Browser-Performance}]
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
def base_dir
|
2022-07-16 23:28:13 +05:30
|
|
|
Rails.root.join(BASE_DIR)
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
def finder(project = nil)
|
2020-04-08 14:13:33 +05:30
|
|
|
Gitlab::Template::Finders::GlobalTemplateFinder.new(
|
2021-03-11 19:13:27 +05:30
|
|
|
self.base_dir,
|
|
|
|
self.extension,
|
|
|
|
self.categories,
|
|
|
|
self.include_categories_for_file,
|
|
|
|
excluded_patterns: self.excluded_patterns
|
2020-04-08 14:13:33 +05:30
|
|
|
)
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
Gitlab::Template::GitlabCiYmlTemplate.prepend_mod
|