Expose project runners for build in job API
Problem to solve
Translate the template below into a JSON response in the Projects::JobsController#show.json
as part of gitlab-org/gitlab-ce#50101
.build-page.js-build-page
#js-build-header-vue
- if @build.stuck?
- unless @build.any_runners_online?
.bs-callout.bs-callout-warning.js-build-stuck
%p
- if no_runners_for_project?(@build.project)
This job is stuck, because the project doesn't have any runners online assigned to it.
- elsif @build.tags.any?
This job is stuck, because you don't have any active runners online with any of these tags assigned to them:
- @build.tags.each do |tag|
%span.badge.badge-primary
= tag
- else
This job is stuck, because you don't have any active runners that can run this job.
%br
Go to
= link_to project_runners_path(@build.project, anchor: 'js-runners-settings') do
Runners page
Further details
The response will include a new key runners
that has the information below, which can be used to translate the haml
above.
...
"runners": {
"online": true,
"available": false,
"settings_path": "/root/artifacts/runners#js-runners-settings"
}
...
The above json can be used to translate the haml
from above template as the following
haml | json |
---|---|
- if @build.stuck? |
status.pending && !runners.online |
unless @build.any_runners_online? |
runners.oneline |
no_runners_for_project?(@build.project) |
runners.available |
@build.tags.any? |
tags |
ink_to project_runners_path(@build.project, anchor: 'js-runners-settings') |
runners.settings_path |
Edited by Steve Xuereb