Pipeline status badge auto update

We have set up a pipeline for a python package in our repository. It’s running on free tier.

The pipeline (consists of unit tests and etc.) is set up to run on merge requests to the default branch. When a new merge request is created, it does run automatically and all, and it’d be merged by the reviewer if it passes. The issue starts after this.

The pipeline status badge will show pipeline status as unknown at this point. I think it’s because the pipeline is run on the other branch’s latest updated code, and not on the main branch. If I trigger a run on main branch manually, it’ll then change the status appropriately.

Since I’ve set up that only fast forward merge requests are accepted, and no separate merge commit is performed, I thought it’d handle this indirectly as the pipeline on the feature/bugfix branch is essentially run on the same commit. But tit’s not the case, and we have to intervene manually.

Questions:

  1. Why is it happening? Is it because we merge by squashing commits? But in that case, I’d expect it to be updated automatically for the bugfix merge requests with just one commits, which is not the case.
  2. Is it possible for the badge to be outdated based on the commit id on which pipeline was run, instead of the branch?
  3. If not, is it possible to trigger a new pipeline on the main branch automatically after the merge request is approved and merged?

Hi @anirban.ray :wave: That sounds like a case of gitlab#215530 (pipeline badges only reflect “commit” pipelines. should have separate pipeline badges for different pipeline triggers). Please upvote that issue, if you agree. Thank you & kind regards!

Thanks for your response, @katrinleinweber (here, and in SO comment)

I agree it’s the same case, and upvoted. But can you please suggest some workaround for the time being? I’m thinking to change workflow rules.

From:

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

to something like this (not tested):

workflow:
    rules:
        - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
          when: never
        - when: always

But I’m really not sure if it covers all situations. Any feedbacks?

@anirban.ray Let’s move your question to gitlab#215530.