Welcome to mirror list, hosted at ThFree Co, Russian Federation.

retry.rb « job « ci « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5ccc33de33e0f5cccc6cd70cfb9fe27310d6abb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

module Mutations
  module Ci
    module Job
      class Retry < Base
        graphql_name 'JobRetry'

        JobID = ::Types::GlobalIDType[::Ci::Processable]

        argument :id, JobID,
                 required: true,
                 description: 'ID of the job to mutate.'

        field :job,
              Types::Ci::JobType,
              null: true,
              description: 'Job after the mutation.'

        argument :variables, [::Types::Ci::VariableInputType],
                 required: false,
                 default_value: [],
                 replace_null_with_default: true,
                 description: 'Variables to use when retrying a manual job.'

        authorize :update_build

        def resolve(id:, variables:)
          job = authorized_find!(id: id)
          project = job.project
          variables = variables.map(&:to_h)

          response = ::Ci::RetryJobService.new(project, current_user).execute(job, variables: variables)

          if response.success?
            {
              job: response[:job],
              errors: []
            }
          else
            {
              job: nil,
              errors: [response.message]
            }
          end
        end
      end
    end
  end
end