Managing secrets and configuration in GitLab pipelines doesnβt have to be messy. Hereβs a quick guide to securely upload your environment variables and integrate them into your .gitlab-ci.yml workflow.

Autotest:
stage: test
image: node:22
before_script:
- cat "$ENV_VARS" | tr -d '\r' > .env
Youβve now securely injected environment variables into your GitLab CI/CD pipeline. No more hardcoding secrets or juggling config filesβjust clean, maintainable automation.
More...
- In Gitlab goto left side bar, Settings, CI/CD
- Go to variables section, click add variable
- From right side bar select select visible and deselect protect variable

- In Key write the name of the file that will store all the variables
- In value enter the key and values of your variables (values are written without ")
- Make sure that your yml script adds the env vars file
.gitlab-ci.yml
Autotest:
stage: test
image: node:22
before_script:
- cat "$ENV_VARS" | tr -d '\r' > .env
Youβve now securely injected environment variables into your GitLab CI/CD pipeline. No more hardcoding secrets or juggling config filesβjust clean, maintainable automation.
More...