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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
module Gitlab
module Ci
class Config
module Entry
##
# Entry that represents a configuration of job artifacts.
#
class Artifacts < Node
include Configurable
include Validatable
include Attributable
ALLOWED_KEYS = %i[name untracked paths reports when expire_in].freeze
attributes ALLOWED_KEYS
entry :reports, Entry::Reports,
description: 'Report-type artifacts.'
validations do
validates :config, type: Hash
validates :config, allowed_keys: ALLOWED_KEYS
with_options allow_nil: true do
validates :name, type: String
validates :untracked, boolean: true
validates :paths, array_of_strings: true
validates :reports, type: Hash
validates :when,
inclusion: { in: %w[on_success on_failure always],
message: 'should be on_success, on_failure ' \
'or always' }
validates :expire_in, duration: true
end
end
helpers :reports
def value
@config[:reports] = reports_value if @config.key?(:reports)
@config
end
def present_for_runner
@config.merge(artifact_type: :archive, artifact_format: :zip)
end
end
class ArtifactsForRunner < Node
include Validatable
include Attributable
ALLOWED_KEYS = %i[name untracked paths when expire_in artifact_type artifact_format].freeze
attributes ALLOWED_KEYS
validations do
validates :config, type: Hash
validates :config, allowed_keys: ALLOWED_KEYS
validates :artifact_type, type: Symbol
validates :artifact_format, type: Symbol
with_options if: :general_artifact? do
with_options allow_nil: true do
validates :name, type: String
validates :untracked, boolean: true
validates :paths, array_of_strings: true
validates :when, inclusion: { in: %w[on_success on_failure always] }
validates :expire_in, duration: true
end
end
with_options if: :report_artifact? do
validates :name, type: String
validates :untracked, presence: false
validates :paths, array_of_strings: true
validates :when, inclusion: { in: %w[always] }
validates :expire_in, presence: false
end
end
def general_artifact?
::Ci::JobArtifact::GENERAL_ARCHIVE_FILE_TYPE == @config[:artifact_type]
end
def report_artifact?
::Ci::JobArtifact::TEST_REPORT_FILE_TYPES.include?(@config[:artifact_type])
end
end
end
end
end
end
|