Class: Ci::Pipelines::AddJobService
- Inherits:
-
Object
- Object
- Ci::Pipelines::AddJobService
- Includes:
- Gitlab::ExclusiveLeaseHelpers
- Defined in:
- app/services/ci/pipelines/add_job_service.rb
Constant Summary
Constants included from Gitlab::ExclusiveLeaseHelpers
Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError
Instance Attribute Summary collapse
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
Instance Method Summary collapse
- #execute!(job, &block) ⇒ Object
-
#initialize(pipeline) ⇒ AddJobService
constructor
A new instance of AddJobService.
Methods included from Gitlab::ExclusiveLeaseHelpers
Constructor Details
#initialize(pipeline) ⇒ AddJobService
Returns a new instance of AddJobService.
10 11 12 13 14 |
# File 'app/services/ci/pipelines/add_job_service.rb', line 10 def initialize(pipeline) @pipeline = pipeline raise ArgumentError, "Pipeline must be persisted for this service to be used" unless pipeline.persisted? end |
Instance Attribute Details
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline.
8 9 10 |
# File 'app/services/ci/pipelines/add_job_service.rb', line 8 def pipeline @pipeline end |
Instance Method Details
#execute!(job, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/ci/pipelines/add_job_service.rb', line 16 def execute!(job, &block) assign_pipeline_attributes(job) in_lock("ci:pipelines:#{pipeline.id}:add-job", ttl: LOCK_TIMEOUT, sleep_sec: LOCK_SLEEP, retries: LOCK_RETRIES) do Ci::Pipeline.transaction do yield(job) job.update_older_statuses_retried! end end ServiceResponse.success(payload: { job: job }) rescue StandardError => e ServiceResponse.error(message: e., payload: { job: job }) end |