Feedback

Chat Icon

Cloud Native CI/CD with GitLab

From Commit to Production Ready

Managing and Storing Data, Variables, and Secrets
33%

Using Files as CI/CD Variables/Secrets

In the previous example, we used a variable to store the Slack webhook URL. We could also use a file to store the URL. You can follow the same procedure as before to add a new variable, but this time, select the File type, name the key SLACK_WEBHOOK_URL_FILE and in the Value field, paste the Slack webhook URL.

You should also update the .gitlab-ci.yml file to use the file as a variable:

image: python:3.12

stages:
  - build
  - test

pre-build:
  stage: .pre
  script:
    - >
      python3 --version |
      grep "Python 3.12" ||
      exit 1

build:
  stage: build
  script:
    - pip install -r requirements.txt

test:
  stage: test
  script:
    - pip install -r requirements.txt
    - pip install flake8==7.1.1
    - flake8 --statistics
    - python3 test_app.py

post-test:
  stage: .post

Cloud Native CI/CD with GitLab

From Commit to Production Ready

Enroll now to unlock all content and receive all future updates for free.