2021-05-06 17:10:07 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module Ci
|
|
|
|
module Job
|
|
|
|
class Retry < Base
|
|
|
|
graphql_name 'JobRetry'
|
|
|
|
|
|
|
|
field :job,
|
|
|
|
Types::Ci::JobType,
|
|
|
|
null: true,
|
2021-08-10 08:11:00 -04:00
|
|
|
description: 'Job after the mutation.'
|
2021-05-06 17:10:07 -04:00
|
|
|
|
2022-08-12 14:11:09 -04:00
|
|
|
argument :variables, [::Types::Ci::VariableInputType],
|
|
|
|
required: false,
|
|
|
|
default_value: [],
|
|
|
|
replace_null_with_default: true,
|
|
|
|
description: 'Variables to use when retrying a manual job.'
|
|
|
|
|
2021-05-06 17:10:07 -04:00
|
|
|
authorize :update_build
|
|
|
|
|
2022-08-12 14:11:09 -04:00
|
|
|
def resolve(id:, variables:)
|
2021-05-06 17:10:07 -04:00
|
|
|
job = authorized_find!(id: id)
|
|
|
|
project = job.project
|
2022-08-12 14:11:09 -04:00
|
|
|
variables = variables.map(&:to_h)
|
2021-05-06 17:10:07 -04:00
|
|
|
|
2022-08-12 14:11:09 -04:00
|
|
|
response = ::Ci::RetryJobService.new(project, current_user).execute(job, variables: variables)
|
2022-03-23 14:08:47 -04:00
|
|
|
|
|
|
|
if response.success?
|
|
|
|
{
|
|
|
|
job: response[:job],
|
|
|
|
errors: []
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
job: nil,
|
|
|
|
errors: [response.message]
|
|
|
|
}
|
|
|
|
end
|
2021-05-06 17:10:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|