Class: Environments::CreateForJobService
- Inherits:
-
Object
- Object
- Environments::CreateForJobService
- Defined in:
- app/services/environments/create_for_job_service.rb
Overview
This class creates an environment record for a pipeline job.
Instance Method Summary collapse
Instance Method Details
#execute(job) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/services/environments/create_for_job_service.rb', line 6 def execute(job) return unless job.is_a?(::Ci::Processable) && job.has_environment_keyword? environment = to_resource(job) if environment.persisted? job.persisted_environment = environment job.assign_attributes(metadata_attributes: { expanded_environment_name: environment.name }) else job.assign_attributes(status: :failed, failure_reason: :environment_creation_failure) end environment end |