Search code examples
gitlabgitlab-cicicd

The proper way to define variables in GitLab CI/CD settings to disable jobs in a pipeline


I am trying to define environment variables for a project in GitLab to customise the Auto Dev Ops pipeline to disable the code quality jobs in all environments. When I try to define the variable, it asks me for a key and a value (As shown below). variable definition pop up in GitLab CI/CD settings. Based on the table of disabled jobs variables (https://docs.gitlab.com/ee/topics/autodevops/customize.html#disable-jobs) I chose CODE_QUALITY_DISABLED and set the value to true but when I try to commit a new change to test the pipeline it still runs the quality check. I wonder What am I doing wrong here.


Solution

  • Without more information on what your CI file looks like (or if you have one at all), then it may be difficult to answer, but there are a few possibilities.

    1. If you have a CI file and you've set the variable to be false, that will override what's in the project settings.
    2. You're using a version older than 11.0 (unlikely but possible).
    3. You're committing changes to an unprotected branch.

    For the last one, if you want the code quality to be disabled for all pipelines, then you want to make sure the "Protect variable" option is unchecked (whereas your screenshot shows it as checked), because a protected variable will only apply to protected branches and tags.