Fix merge request head pipeline when pipeline has errors
What does this MR do?
This MR fixes incorrectly assigned merge request head pipeline, when pipeline has error (like YAML validation errors).
Does this MR meet the acceptance criteria?
- Changelog entry added
- Tests added for this bug
- Has been reviewed by Backend
What are the relevant issue numbers?