How to Define Variables for an Automation Script

2.5.5. How to Define Variables for an Automation Script#

GitLab allows the use of variables in the definition of Pipelines and provides a variety of predefined variables.

We can differentiate between:

  • Predefined Variables:

    These variables typically start with CI_... and contain information about the Project, Pipeline, job, and more.

Warning

Sensitive data should be stored outside of GitLab! Half-way acceptable is to use protected and masked custom variables

  • Custom Variables:

    These variables can be set via the Web-UI and can be used to store configuration values or secrets that your jobs need to access.

myjob:
  stage: test
  script:
    - echo "This job run in stage: '$CI_JOB_STAGE'"