| ... | @@ -28,7 +28,7 @@ module Gitlab |
... | @@ -28,7 +28,7 @@ module Gitlab |
|
|
@except = Gitlab::Ci::Build::Policy
|
|
@except = Gitlab::Ci::Build::Policy
|
|
|
.fabricate(attributes.delete(:except))
|
|
.fabricate(attributes.delete(:except))
|
|
|
@rules = Gitlab::Ci::Build::Rules
|
|
@rules = Gitlab::Ci::Build::Rules
|
|
|
.new(attributes.delete(:rules))
|
|
.new(attributes.delete(:rules), default_when: 'on_success')
|
|
|
@cache = Seed::Build::Cache
|
|
@cache = Seed::Build::Cache
|
|
|
.new(pipeline, attributes.delete(:cache))
|
|
.new(pipeline, attributes.delete(:cache))
|
|
|
end
|
|
end
|
| ... | @@ -40,7 +40,7 @@ module Gitlab |
... | @@ -40,7 +40,7 @@ module Gitlab |
|
|
def included?
|
|
def included?
|
|
|
strong_memoize(:inclusion) do
|
|
strong_memoize(:inclusion) do
|
|
|
if @using_rules
|
|
if @using_rules
|
|
|
included_by_rules?
|
|
rules_result.pass?
|
|
|
elsif @using_only || @using_except
|
|
elsif @using_only || @using_except
|
|
|
all_of_only? && none_of_except?
|
|
all_of_only? && none_of_except?
|
|
|
else
|
|
else
|
| ... | @@ -83,26 +83,14 @@ module Gitlab |
... | @@ -83,26 +83,14 @@ module Gitlab |
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def scoped_variables_hash
|
|
|
|
|
strong_memoize(:scoped_variables_hash) do
|
|
|
|
|
# This is a temporary piece of technical debt to allow us access
|
|
|
|
|
# to the CI variables to evaluate rules before we persist a Build
|
|
|
|
|
# with the result. We should refactor away the extra Build.new,
|
|
|
|
|
# but be able to get CI Variables directly from the Seed::Build.
|
|
|
|
|
::Ci::Build.new(
|
|
|
|
|
@seed_attributes.merge(pipeline_attributes)
|
|
|
|
|
).scoped_variables_hash
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
private
|
|
|
|
|
|
|
|
def all_of_only?
|
|
def all_of_only?
|
|
|
@only.all? { |spec| spec.satisfied_by?(@pipeline, self) }
|
|
@only.all? { |spec| spec.satisfied_by?(@pipeline, evaluate_context) }
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def none_of_except?
|
|
def none_of_except?
|
|
|
@except.none? { |spec| spec.satisfied_by?(@pipeline, self) }
|
|
@except.none? { |spec| spec.satisfied_by?(@pipeline, evaluate_context) }
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def needs_errors
|
|
def needs_errors
|
| ... | @@ -144,13 +132,21 @@ module Gitlab |
... | @@ -144,13 +132,21 @@ module Gitlab |
|
|
}
|
|
}
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def included_by_rules?
|
|
def rules_attributes
|
|
|
rules_attributes[:when] != 'never'
|
|
return {} unless @using_rules
|
|
|
|
|
|
|
|
rules_result.build_attributes
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def rules_attributes
|
|
def rules_result
|
|
|
strong_memoize(:rules_attributes) do
|
|
strong_memoize(:rules_result) do
|
|
|
@using_rules ? @rules.evaluate(@pipeline, self).build_attributes : {}
|
|
@rules.evaluate(@pipeline, evaluate_context)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def evaluate_context
|
|
|
|
strong_memoize(:evaluate_context) do
|
|
|
|
Gitlab::Ci::Build::Context::Build.new(@pipeline, @seed_attributes)
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
| ... | |
... | |
| ... | | ... | |