Loading
Return evidence id when creating release evidence via API
What does this MR do and why?
Closes #214819
When generating release evidence through the API (POST /projects/:id/releases/:tag_name/evidence), GitLab previously scheduled a background job and returned 202 Accepted with an empty response body. Callers had no identifier or handle to track or retrieve the generated evidence.
This MR resolves this by:
- Immediately creating a stub evidence record (with empty summary) in
ee/lib/ee/api/releases.rb. - Scheduling
CreateEvidenceWorkerpassingrelease.id,evidence_pipeline&.id, andevidence.idso the worker asynchronously collects the summary and sha for that specific evidence. - Exposing
idinAPI::Entities::Releases::Evidencealongsidesha,filepath, andcollected_at. - Returning the serialized evidence record in the
202 Acceptedresponse. - Updating
Releases::CreateEvidenceServiceandReleases::CreateEvidenceWorkerto accept an optionalevidence:parameter, ensuring 100% backward compatibility with other worker callers and existing in-flight jobs. - Updating OpenAPI v3 documentation (
doc/api/openapi/openapi_v3.yaml) and API documentation (doc/api/releases/_index.md).
Verification
- Added request specs in
ee/spec/requests/api/releases_spec.rbverifying response body includesid, job token authorization, and Sidekiq scheduling. - Added service specs in
spec/services/releases/create_evidence_service_spec.rbtesting updates to existing evidence stub without creating duplicate records. - Added worker specs in
spec/workers/releases/create_evidence_worker_spec.rbensuring stub evidence is populated whenevidence_idis supplied and verifying backward compatibility when omitted. - Validated Ruby syntax and OpenAPI specifications across all modified files.
MR Acceptance Checklist
- Conforms to GitLab Ruby style guidelines
- Preserves backward compatibility for Sidekiq worker invocations
- Updated OpenAPI v3 documentation and user API docs
- Verified with request, service, and worker specs