Class: Gitlab::Ci::Config::Entry::Job

Inherits:
Gitlab::Config::Entry::Node show all
Includes:
Processable
Defined in:
lib/gitlab/ci/config/entry/job.rb

Overview

Entry that represents a concrete CI/CD job.

Constant Summary collapse

ALLOWED_WHEN =
%w[on_success on_failure always manual delayed].freeze
ALLOWED_KEYS =
%i[tags script image services start_in artifacts
cache dependencies before_script after_script hooks
coverage retry parallel interruptible timeout
release id_tokens publish].freeze

Constants included from Processable

Processable::MAX_NESTING_LEVEL, Processable::PROCESSABLE_ALLOWED_KEYS

Constants included from Gitlab::Config::Entry::Inheritable

Gitlab::Config::Entry::Inheritable::InheritError

Constants inherited from Gitlab::Config::Entry::Node

Gitlab::Config::Entry::Node::InvalidError

Instance Attribute Summary

Attributes inherited from Gitlab::Config::Entry::Node

#config, #default, #deprecation, #description, #key, #metadata, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Processable

#compose!, #manual_action?, #name, #overwrite_entry, #root_variables_inheritance, #validate_against_warnings

Methods included from Gitlab::Config::Entry::Inheritable

#compose!

Methods included from Gitlab::Config::Entry::Configurable

#compose!, #entry_create!, #skip_config_hash_validation?

Methods inherited from Gitlab::Config::Entry::Node

#[], #add_warning, #ancestors, #array?, aspects, #compose!, default, #descendants, #errors, #hash?, #initialize, #inspect, #integer?, #leaf?, #location, #opt, #relevant?, #specified?, #string?, #valid?, #warnings, with_aspect

Constructor Details

This class inherits a constructor from Gitlab::Config::Entry::Node

Class Method Details

.allowed_keysObject



191
192
193
# File 'lib/gitlab/ci/config/entry/job.rb', line 191

def self.allowed_keys
  ALLOWED_KEYS
end

.matching?(name, config) ⇒ Boolean

Returns:

  • (Boolean)


135
136
137
138
# File 'lib/gitlab/ci/config/entry/job.rb', line 135

def self.matching?(name, config)
  !name.to_s.start_with?('.') &&
    config.is_a?(Hash) && config.key?(:script)
end

.visible?Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/gitlab/ci/config/entry/job.rb', line 140

def self.visible?
  true
end

Instance Method Details

#delayed?Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/gitlab/ci/config/entry/job.rb', line 144

def delayed?
  self.when == 'delayed'
end

#ignored?Boolean

Returns:

  • (Boolean)


183
184
185
# File 'lib/gitlab/ci/config/entry/job.rb', line 183

def ignored?
  allow_failure_defined? ? static_allow_failure : manual_action?
end

#pages_job?Boolean

Returns:

  • (Boolean)


187
188
189
# File 'lib/gitlab/ci/config/entry/job.rb', line 187

def pages_job?
  name == :pages
end

#parsed_timeoutObject



177
178
179
180
181
# File 'lib/gitlab/ci/config/entry/job.rb', line 177

def parsed_timeout
  return unless has_timeout?

  ChronicDuration.parse(timeout.to_s, use_complete_matcher: true)
end

#valueObject



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/gitlab/ci/config/entry/job.rb', line 148

def value
  super.merge(
    before_script: before_script_value,
    script: script_value,
    image: image_value,
    services: services_value,
    cache: cache_value,
    tags: tags_value,
    when: self.when,
    start_in: self.start_in,
    dependencies: dependencies,
    coverage: coverage_defined? ? coverage_value : nil,
    retry: retry_defined? ? retry_value : nil,
    parallel: has_parallel? ? parallel_value : nil,
    interruptible: interruptible_defined? ? interruptible_value : nil,
    timeout: parsed_timeout,
    artifacts: artifacts_value,
    release: release_value,
    after_script: after_script_value,
    hooks: hooks_value,
    ignore: ignored?,
    allow_failure_criteria: allow_failure_criteria,
    needs: needs_defined? ? needs_value : nil,
    scheduling_type: needs_defined? ? :dag : :stage,
    id_tokens: id_tokens_value,
    publish: publish
  ).compact
end