Code Quality Widget is not shown in Merge Request

Describe your question in as much detail as possible:

I have integrated a code quality check with a standard setup:

include:
    - template: Code-Quality.gitlab-ci.yml

code_quality:
    services: []
    tags:
        - cq-sans-dind
    rules:
        -   if: '$CODE_QUALITY_DISABLED'
            when: never
        -   if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "next" || $CI_COMMIT_BRANCH =~ /^release/ || $CI_PIPELINE_SOURCE == "merge_request_event"'

I can see the “Code Quality” Tab in pipelines (we have a Premium SaaS Plan) and the code quality report was already done on “master”.

However, when a MR to “master” is created I see no “Code Quality Widget” in a Merge Request view. I still can go to a pipeline of a MR and see the “Code Quality” tab there.

Not sure, but maybe it is related to the way our pipelines are built - we use cleanup jobs in MR environments, which are activated, when MR is merged:

deploy:s3:
  ...
  environment:
    name: s3/$CI_COMMIT_REF_NAME
    on_stop: deploy:s3:cleanup

deploy:s3:cleanup:
  ...  
  environment:
      name: s3/$CI_COMMIT_REF_NAME
      action: stop

Therefore a pipeline is shown as “blocked”, unless MR is merged.

Do you have any ideas, how to enable the Code Quality Widget in MR view?

Have found solution myself - it was exactly related to the cleanup jobs, which were causing the “blocked” state of a pipeline. Solution was to add to these jobs:

allow_failure: true

So, the pipeline is shown as “succeeded” and Code Quality Widget is there.

1 Like