Class: Types::Ci::JobType
Overview
rubocop: disable Graphql/AuthorizeTypes The permission is presented through ‘StageType` that has its own authorization
Instance Method Summary
collapse
Methods inherited from BaseObject
accepts, assignable?, authorization, authorization_scopes, authorize, authorized?, #current_user
#present, #unpresented
Instance Method Details
#artifacts ⇒ Object
168
169
170
|
# File 'app/graphql/types/ci/job_type.rb', line 168
def artifacts
object.job_artifacts if object.is_a?(::Ci::Build)
end
|
#browse_artifacts_path ⇒ Object
258
259
260
|
# File 'app/graphql/types/ci/job_type.rb', line 258
def browse_artifacts_path
::Gitlab::Routing.url_helpers.browse_project_job_artifacts_path(object.project, object)
end
|
#can_play_job? ⇒ Boolean
138
139
140
|
# File 'app/graphql/types/ci/job_type.rb', line 138
def can_play_job?
object.playable? && Ability.allowed?(current_user, :play_job, object)
end
|
#commit_path ⇒ Object
238
239
240
|
# File 'app/graphql/types/ci/job_type.rb', line 238
def commit_path
::Gitlab::Routing.url_helpers.project_commit_path(object.project, object.sha)
end
|
#coverage ⇒ Object
262
263
264
|
# File 'app/graphql/types/ci/job_type.rb', line 262
def coverage
object&.coverage
end
|
#detailed_status ⇒ Object
164
165
166
|
# File 'app/graphql/types/ci/job_type.rb', line 164
def detailed_status
object.detailed_status(context[:current_user])
end
|
#downstream_pipeline ⇒ Object
156
157
158
|
# File 'app/graphql/types/ci/job_type.rb', line 156
def downstream_pipeline
object.downstream_pipeline if object.respond_to?(:downstream_pipeline)
end
|
#exit_code ⇒ Object
282
283
284
|
# File 'app/graphql/types/ci/job_type.rb', line 282
def exit_code
object.exit_code if object.build.respond_to?(:exit_code)
end
|
#id ⇒ Object
This class is a secret union! TODO: turn this into an actual union, so that fields can be referenced safely!
230
231
232
233
234
235
236
|
# File 'app/graphql/types/ci/job_type.rb', line 230
def id
return unless object.id.present?
model_name = object.type || ::CommitStatus.name
id = object.id
Gitlab::GlobalId.build(model_name: model_name, id: id)
end
|
#kind ⇒ Object
142
143
144
145
146
|
# File 'app/graphql/types/ci/job_type.rb', line 142
def kind
return ::Ci::Build unless [::Ci::Build, ::Ci::Bridge].include?(object.build.class)
object.build.class
end
|
#manual_job ⇒ Object
266
267
268
|
# File 'app/graphql/types/ci/job_type.rb', line 266
def manual_job
object.try(:action?)
end
|
#manual_variables ⇒ Object
274
275
276
277
278
279
280
|
# File 'app/graphql/types/ci/job_type.rb', line 274
def manual_variables
if object.action? && object.respond_to?(:job_variables)
object.job_variables
else
[]
end
end
|
#play_path ⇒ Object
254
255
256
|
# File 'app/graphql/types/ci/job_type.rb', line 254
def play_path
::Gitlab::Routing.url_helpers.play_project_job_path(object.project, object)
end
|
#previous_stage_jobs ⇒ Object
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
# File 'app/graphql/types/ci/job_type.rb', line 190
def previous_stage_jobs
BatchLoader::GraphQL.for([object.pipeline_id, object.stage_idx - 1]).batch(default_value: []) do |tuples, loader|
pipeline_ids = tuples.map(&:first).uniq
stage_idxs = tuples.map(&:second).uniq
jobs = CommitStatus.in_pipelines(pipeline_ids).for_stage(stage_idxs).latest
grouped_jobs = jobs.group_by { |job| [job.pipeline_id, job.stage_idx] }
tuples.each do |tuple|
loader.call(tuple, grouped_jobs.fetch(tuple, []))
end
end
end
|
#previous_stage_jobs_or_needs ⇒ Object
180
181
182
183
184
185
186
187
188
|
# File 'app/graphql/types/ci/job_type.rb', line 180
def previous_stage_jobs_or_needs
if object.scheduling_type == 'stage'
Gitlab::Graphql::Lazy.with_value(previous_stage_jobs) do |jobs|
jobs
end
else
object.needs
end
end
|
#ref_name ⇒ Object
242
243
244
|
# File 'app/graphql/types/ci/job_type.rb', line 242
def ref_name
object&.ref
end
|
#ref_path ⇒ Object
246
247
248
|
# File 'app/graphql/types/ci/job_type.rb', line 246
def ref_path
::Gitlab::Routing.url_helpers.project_commits_path(object.project, ref_name)
end
|
#retryable ⇒ Object
148
149
150
|
# File 'app/graphql/types/ci/job_type.rb', line 148
def retryable
object.build.retryable?
end
|
#runner_manager ⇒ Object
214
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'app/graphql/types/ci/job_type.rb', line 214
def runner_manager
BatchLoader::GraphQL.for(object.id).batch(key: :runner_managers) do |build_ids, loader|
plucked_build_to_runner_manager_ids =
::Ci::RunnerManagerBuild.for_build(build_ids).pluck_build_id_and_runner_manager_id
runner_managers = ::Ci::RunnerManager.id_in(plucked_build_to_runner_manager_ids.values.uniq)
Preloaders::RunnerManagerPolicyPreloader.new(runner_managers, current_user).execute
runner_managers_by_id = runner_managers.index_by(&:id)
build_ids.each do |build_id|
loader.call(build_id, runner_managers_by_id[plucked_build_to_runner_manager_ids[build_id]])
end
end
end
|
#source ⇒ Object
172
173
174
|
# File 'app/graphql/types/ci/job_type.rb', line 172
def source
object.source if object.is_a?(::Ci::Build)
end
|
160
161
162
|
# File 'app/graphql/types/ci/job_type.rb', line 160
def tags
object.tags.map(&:name) if object.is_a?(::Ci::Build)
end
|
#trace ⇒ Object
176
177
178
|
# File 'app/graphql/types/ci/job_type.rb', line 176
def trace
object.trace if object.has_trace?
end
|
#triggered ⇒ Object
270
271
272
|
# File 'app/graphql/types/ci/job_type.rb', line 270
def triggered
object.try(:trigger_request)
end
|
#web_path ⇒ Object
250
251
252
|
# File 'app/graphql/types/ci/job_type.rb', line 250
def web_path
::Gitlab::Routing.url_helpers.project_job_path(object.project, object)
end
|