'Update gitlab badges

Setup

On a self-hosted Gitlab instance, we have a python package. A CI is set up to be triggered for every merge request into the main branch to run unit tests, and if that succeeds, then to build and release the new version into registry.

It's set in settings so that only fast forward merge requests can be merged.

Issue

Recently, we have set up a badge to display pipeline status. This has been done following the documentation. If we now run a pipeline on the main branch manually, it's working fine.

However, whenever a merge request is approved and merged, the status gets changed to unknown. It shows appropriate labels only when it's run manually on the main branch, not on a feature or bugfix branch as part of CI.

Question

Since the latest commit id remains same for both the merge request source branch and the updated main branch, my expectation was that it should show status of the same. Why is that not happening. (I have verified that using squashing does not have any effect, as even a single test commit leads to unknown.)


Configurations

Workflow Rule (run for all non-push events)

workflow:
    rules:
        - if: '$CI_PIPELINE_SOURCE == "push"'
          when: never
        - when: always

Badge Settings

Name: Pipeline Status
Link: https://<our_gitlab_url>/%{project_path}/-/commits/%{default_branch}
Badge Image URL: https://<our_gitlab_url>/%{project_path}/badges/%{default_branch}/pipeline.svg


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source