Skip to content

Only print necessary env vars in tests

Steve Xuereb requested to merge refactor/stop-test-from-print-all-env-vars into main

What does this MR do?

Only print necessary env vars in tests

Why was this MR needed?

When using the env or set keyword it prints all the environments that are available in the job. These can be problematic printing environments that we shouldn't print. Update the tests to run an echo on the specific variables that we are testing instead. This makes running the tests safer since it won't print in every environment.

In !2951 (merged) we only allow certain environment variables, however, it's better to have multiple layers of protection rather than 1 just in case 1 of them regresses.

What's the best way to test this MR?

Make sure that NOT_HERE environment variable isn't printed.

NOT_HERE=NOT_HERE go test -v -run TestBuildJobStatusEnvVars -tags integration ./executors/shell/ | grep 'NOT_HERE'

What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27963

Edited by Steve Xuereb

Merge request reports