Class: Ci::EnqueueJobService
- Inherits:
-
Object
- Object
- Ci::EnqueueJobService
- Defined in:
- app/services/ci/enqueue_job_service.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#job ⇒ Object
Returns the value of attribute job.
-
#variables ⇒ Object
Returns the value of attribute variables.
Instance Method Summary collapse
- #execute(&transition) ⇒ Object
-
#initialize(job, current_user:, variables: nil) ⇒ EnqueueJobService
constructor
A new instance of EnqueueJobService.
Constructor Details
#initialize(job, current_user:, variables: nil) ⇒ EnqueueJobService
Returns a new instance of EnqueueJobService.
7 8 9 10 11 |
# File 'app/services/ci/enqueue_job_service.rb', line 7 def initialize(job, current_user:, variables: nil) @job = job @current_user = current_user @variables = variables end |
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
5 6 7 |
# File 'app/services/ci/enqueue_job_service.rb', line 5 def current_user @current_user end |
#job ⇒ Object
Returns the value of attribute job.
5 6 7 |
# File 'app/services/ci/enqueue_job_service.rb', line 5 def job @job end |
#variables ⇒ Object
Returns the value of attribute variables.
5 6 7 |
# File 'app/services/ci/enqueue_job_service.rb', line 5 def variables @variables end |
Instance Method Details
#execute(&transition) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/ci/enqueue_job_service.rb', line 13 def execute(&transition) transition ||= ->(job) { job.enqueue! } Gitlab::OptimisticLocking.retry_lock(job, name: 'ci_enqueue_job') do |job| job.user = current_user job.job_variables_attributes = variables if variables transition.call(job) end ResetSkippedJobsService.new(job.project, current_user).execute(job) job end |