K6_STATSD_ENABLE_TAGS=true is not working when K6 command is executed via bash script

When I run K6 command like “K6_STATSD_ENABLE_TAGS=true k6 run -e env=staging --out statsd ./tests/k6-Catalog.js”, I see the metrics popping up in Datadog.

I have created bash script and it runs the command like “K6_STATSD_ENABLE_TAGS=true k6 run -e type=$testType -e env=$environment --out statsd ./tests/$script.js”. The script runs fine on my machine, I see the summary at the end but I do not see metrics in Datadog.

I remember there was mention of setting K6_STATSD_ENABLE_TAGS=true in another way but I don’t remember how. Is there a way I can set K6_STATSD_ENABLE_TAGS inside the script or set it as environment variable.

I was using the wrong expression in if condition. Now, it works.