Class: Types::Ci::JobType
Overview
rubocop: disable Graphql/AuthorizeTypes The permission is presented through different types that access JobType
Instance Method Summary
collapse
Methods inherited from BaseObject
accepts, assignable?, authorization, authorization_scopes, authorize, authorized?, #current_user
#present, #unpresented
Instance Method Details
#artifacts ⇒ Object
167
168
169
|
# File 'app/graphql/types/ci/job_type.rb', line 167
def artifacts
object.job_artifacts if object.is_a?(::Ci::Build)
end
|
#browse_artifacts_path ⇒ Object
259
260
261
|
# File 'app/graphql/types/ci/job_type.rb', line 259
def browse_artifacts_path
::Gitlab::Routing.url_helpers.browse_project_job_artifacts_path(object.project, object)
end
|
#can_play_job? ⇒ Boolean
141
142
143
|
# File 'app/graphql/types/ci/job_type.rb', line 141
def can_play_job?
object.playable? && Ability.allowed?(current_user, :play_job, object)
end
|
#commit_path ⇒ Object
237
238
239
|
# File 'app/graphql/types/ci/job_type.rb', line 237
def commit_path
::Gitlab::Routing.url_helpers.project_commit_path(object.project, object.sha)
end
|
#coverage ⇒ Object
263
264
265
|
# File 'app/graphql/types/ci/job_type.rb', line 263
def coverage
object&.coverage
end
|
#downstream_pipeline ⇒ Object
159
160
161
|
# File 'app/graphql/types/ci/job_type.rb', line 159
def downstream_pipeline
object.downstream_pipeline if object.respond_to?(:downstream_pipeline)
end
|
#exit_code ⇒ Object
281
282
283
|
# File 'app/graphql/types/ci/job_type.rb', line 281
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!
229
230
231
232
233
234
235
|
# File 'app/graphql/types/ci/job_type.rb', line 229
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
145
146
147
148
149
|
# File 'app/graphql/types/ci/job_type.rb', line 145
def kind
return ::Ci::Build unless [::Ci::Build, ::Ci::Bridge].include?(object.build.class)
object.build.class
end
|
#manual_variables ⇒ Object
267
268
269
270
271
272
273
274
275
276
277
278
279
|
# File 'app/graphql/types/ci/job_type.rb', line 267
def manual_variables
if object.try(:action?) && !object.is_a?(GenericCommitStatus)
BatchLoader::GraphQL.for(object.id).batch do |job_ids, loader|
variables_by_job_id = ::Ci::JobVariable.for_jobs(job_ids).group_by(&:job_id)
job_ids.each do |id|
loader.call(id, variables_by_job_id[id] || [])
end
end
else
::Ci::JobVariable.none
end
end
|
#play_path ⇒ Object
255
256
257
|
# File 'app/graphql/types/ci/job_type.rb', line 255
def play_path
::Gitlab::Routing.url_helpers.play_project_job_path(object.project, object)
end
|
#previous_stage_jobs ⇒ Object
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
# File 'app/graphql/types/ci/job_type.rb', line 189
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
179
180
181
182
183
184
185
186
187
|
# File 'app/graphql/types/ci/job_type.rb', line 179
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_path ⇒ Object
241
242
243
|
# File 'app/graphql/types/ci/job_type.rb', line 241
def ref_path
::Gitlab::Routing.url_helpers.project_commits_path(object.project, ref_name)
end
|
#retry_path ⇒ Object
249
250
251
252
253
|
# File 'app/graphql/types/ci/job_type.rb', line 249
def retry_path
return unless retryable
::Gitlab::Routing.url_helpers.retry_project_job_path(object.project, object)
end
|
#retryable ⇒ Object
151
152
153
|
# File 'app/graphql/types/ci/job_type.rb', line 151
def retryable
object.build.retryable?
end
|
#runner_manager ⇒ Object
213
214
215
216
217
218
219
220
221
222
223
224
225
|
# File 'app/graphql/types/ci/job_type.rb', line 213
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)
::Ci::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
171
172
173
|
# File 'app/graphql/types/ci/job_type.rb', line 171
def source
object.source if object.is_a?(::Ci::Build)
end
|
163
164
165
|
# File 'app/graphql/types/ci/job_type.rb', line 163
def tags
object.tags.map(&:name) if object.is_a?(::Ci::Build)
end
|
#trace ⇒ Object
175
176
177
|
# File 'app/graphql/types/ci/job_type.rb', line 175
def trace
object.trace if object.has_trace?
end
|
#web_path ⇒ Object
245
246
247
|
# File 'app/graphql/types/ci/job_type.rb', line 245
def web_path
::Gitlab::Routing.url_helpers.project_job_path(object.project, object) unless object.is_a?(::Ci::Bridge)
end
|