Regression: quoted strings values piped to $GITLAB_ENV are escaped
Summary
Regression: quoted strings values piped to $GITLAB_ENV are escaped and included in the export. Resulting in a different behaviour than when using source in bash.
This can result in the usage of these variables being completely broken.
Steps to reproduce
.gitlab-ci.yml
default:
image: mcr.microsoft.com/playwright:v1.47.0
stages:
- test
env-issue:
image: mcr.microsoft.com/playwright:v1.47.0
stage: test
script:
- echo 'SOME_VAL="1"' > samplefile.env
- cat samplefile.env >> $GITLAB_ENV
- source samplefile.env
- echo $SOME_VAL
after_script:
- echo $SOME_VAL
Actual behavior
The variable is wrapped in quotations
Expected behavior
The raw variable
Relevant logs and/or screenshots
job log
[0KRunning with gitlab-runner 17.10.0~pre.41.g5c23fd8e (5c23fd8e)[0;m
[0K on blue-1.saas-linux-small.runners-manager.gitlab.com/default j1aLDqxS, system ID: s_ccdc2f364be8[0;m
section_start:1745958014:prepare_executor
[0K[0K[36;1mPreparing the "docker+machine" executor[0;m[0;m
[0KUsing Docker executor with image mcr.microsoft.com/playwright:v1.47.0 ...[0;m
[0KPulling docker image mcr.microsoft.com/playwright:v1.47.0 ...[0;m
[0KUsing docker image sha256:9907539104460cf9c33140517b1b08b1d54eda367e05c6a2b9485be9185d2032 for mcr.microsoft.com/playwright:v1.47.0 with digest mcr.microsoft.com/playwright@sha256:3d41153494e2b12a5a5fa6e26cf1e854c3997d13758754d46e7bf902b5ba09b1 ...[0;m
section_end:1745958044:prepare_executor
[0Ksection_start:1745958044:prepare_script
[0K[0K[36;1mPreparing environment[0;m[0;m
Running on runner-j1aldqxs-project-55628721-concurrent-0 via runner-j1aldqxs-s-l-s-amd64-1745957960-4c989093...
section_end:1745958051:prepare_script
[0Ksection_start:1745958051:get_sources
[0K[0K[36;1mGetting source from Git repository[0;m[0;m
[32;1mFetching changes with git depth set to 20...[0;m
Initialized empty Git repository in /builds/twkie/gitlab-playwright-currents/.git/
[32;1mCreated fresh repository.[0;m
[32;1mChecking out aa79857e as detached HEAD (ref is local-instance)...[0;m
[32;1mSkipping Git submodules setup[0;m
[32;1m$ git remote set-url origin "${CI_REPOSITORY_URL}" || echo 'Not a git repository; skipping'[0;m
section_end:1745958052:get_sources
[0Ksection_start:1745958052:step_script
[0K[0K[36;1mExecuting "step_script" stage of the job script[0;m[0;m
[0KUsing docker image sha256:9907539104460cf9c33140517b1b08b1d54eda367e05c6a2b9485be9185d2032 for mcr.microsoft.com/playwright:v1.47.0 with digest mcr.microsoft.com/playwright@sha256:3d41153494e2b12a5a5fa6e26cf1e854c3997d13758754d46e7bf902b5ba09b1 ...[0;m
[32;1m$ echo 'SOME_VAL="1"' > samplefile.env[0;m
[32;1m$ cat samplefile.env >> $GITLAB_ENV[0;m
[32;1m$ source samplefile.env[0;m
[32;1m$ echo $SOME_VAL[0;m
1
section_end:1745958052:step_script
[0Ksection_start:1745958052:after_script
[0K[0K[36;1mRunning after_script[0;m[0;m
[32;1mRunning after script...[0;m
[32;1m$ echo $SOME_VAL[0;m
"1"
section_end:1745958053:after_script
[0Ksection_start:1745958053:cleanup_file_variables
[0K[0K[36;1mCleaning up project directory and file based variables[0;m[0;m
section_end:1745958053:cleanup_file_variables
[0K[32;1mJob succeeded[0;m
Environment description
gitlab.com shared runners
Used GitLab Runner version
Running with gitlab-runner 17.10.0~pre.41.g5c23fd8e
Possible fixes
I believe this is a regression/side-effect caused by !5171 (merged)