Commit 02b9b5fa authored by Tiger's avatar Tiger

Expose build failure reason

We can use this to show more informative error messages with
links to documentation etc.
parent de03a8bc
...@@ -45,6 +45,8 @@ class BuildDetailsEntity < JobEntity ...@@ -45,6 +45,8 @@ class BuildDetailsEntity < JobEntity
erase_project_job_path(project, build) erase_project_job_path(project, build)
end end
expose :failure_reason, if: -> (*) { build.failed? }
expose :terminal_path, if: -> (*) { can_create_build_terminal? } do |build| expose :terminal_path, if: -> (*) { can_create_build_terminal? } do |build|
terminal_project_job_path(project, build) terminal_project_job_path(project, build)
end end
......
...@@ -112,5 +112,15 @@ describe BuildDetailsEntity do ...@@ -112,5 +112,15 @@ describe BuildDetailsEntity do
expect(subject['merge_request_path']).to be_nil expect(subject['merge_request_path']).to be_nil
end end
end end
context 'when the build has failed' do
let(:build) { create(:ci_build, :created) }
before do
build.drop!(:unmet_prerequisites)
end
it { is_expected.to include(failure_reason: 'unmet_prerequisites') }
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment