Search code examples
continuous-integrationgitlab-ci

Why is the job variables description element not allowed in gitlab-ci.yml when it is required to prepopulate values in a manual job?


I am trying to implement a manual GitLab CI job on gitlab.com that requires the person triggering the job to specify some variables before starting the job. I want to pre-populate the variables that need to be filled with some default values that that it is easier for the user to start the job I see that this is possible from the documentation on prefilling variables in manual pipelines. I am using the VS Code YMAL plugin and even when I copy the example in the documentation into my yml file I receive validation errors.

When I specify both a description and value I get "Property description is not allowed" and when I specify just the description I get "Incorrect type. Expected one of string, number." I can see from this issue that the s

Partial GitLab CI job showing error

validate-release:
  extends: .release
  stage: validate-release
  variables:
    TEST_SUITE:
      description: "The test suite that will run. Valid options are: 'default', 'short', 'full'."
      value: "default"
    DEPLOY_ENVIRONMENT:
      description: "Select the deployment target. Valid options are: 'canary', 'staging', 'production', or a stable branch of your choice."

Have tried pasting in the example from the docs and also validating the whole file in the GitLab CI/CD Editor which also shows the same error. I was expecting it to work as I have implemented it as per the documentation.


Solution

  • As the docs says in its opening paragraph

    You can use the description and value keywords to define pipeline-level (global) variables that are prefilled when running a pipeline manually. Use the description to explain information such as what the variable is used for, and what the acceptable values are.

    Job-level variables cannot be pre-filled.

    You can only use this structure of description and value to prefill variables at the global level and not at the job level. However you are trying to define this in the job scope. You need to move this variable block to the global scope if you want to use prefilled variables.