Expose build failure reason

We can use this to show more informative error messages with
links to documentation etc.
This commit is contained in:
Tiger 2019-03-27 15:01:35 +11:00
parent de03a8bcb4
commit 02b9b5facf
2 changed files with 12 additions and 0 deletions

View File

@ -45,6 +45,8 @@ class BuildDetailsEntity < JobEntity
erase_project_job_path(project, build)
end
expose :failure_reason, if: -> (*) { build.failed? }
expose :terminal_path, if: -> (*) { can_create_build_terminal? } do |build|
terminal_project_job_path(project, build)
end

View File

@ -112,5 +112,15 @@ describe BuildDetailsEntity do
expect(subject['merge_request_path']).to be_nil
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