debian-mirror-gitlab/lib/gitlab/template/gitlab_ci_yml_template.rb

63 lines
1.5 KiB
Ruby
Raw Normal View History

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
2020-11-24 15:15:51 +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
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
2018-12-05 23:21:45 +05:30
Rails.root.join('lib/gitlab/ci/templates')
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-06-08 01:23:25 +05:30
Gitlab::Template::GitlabCiYmlTemplate.prepend_mod_with('Gitlab::Template::GitlabCiYmlTemplate')