Class: Gitlab::Ci::Build::Rules
- Inherits:
-
Object
- Object
- Gitlab::Ci::Build::Rules
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/build/rules.rb
Defined Under Namespace
Instance Method Summary collapse
- #evaluate(pipeline, context) ⇒ Object
-
#initialize(rule_hashes, default_when:) ⇒ Rules
constructor
A new instance of Rules.
Constructor Details
#initialize(rule_hashes, default_when:) ⇒ Rules
Returns a new instance of Rules.
30 31 32 33 |
# File 'lib/gitlab/ci/build/rules.rb', line 30 def initialize(rule_hashes, default_when:) @rule_list = Rule.fabricate_list(rule_hashes) @default_when = default_when end |
Instance Method Details
#evaluate(pipeline, context) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gitlab/ci/build/rules.rb', line 35 def evaluate(pipeline, context) if @rule_list.nil? Result.new(when: @default_when) elsif matched_rule = match_rule(pipeline, context) Result.new( when: matched_rule.attributes[:when] || @default_when, start_in: matched_rule.attributes[:start_in], allow_failure: matched_rule.attributes[:allow_failure], variables: matched_rule.attributes[:variables], needs: matched_rule.attributes[:needs], auto_cancel: matched_rule.attributes[:auto_cancel], interruptible: matched_rule.attributes[:interruptible] ) else Result.new(when: 'never') end rescue Rule::Clause::ParseError => e Result.new(when: 'never', errors: [e.]) end |