## TL;DR

Setting an env var in the step 3 script does not carry over, because each build step runs its own process.

## Steps

1. From your step 3 script, print this exact line to stdout: ##teamcity[setParameter name='env.PASSED_ID' value='the-id-here'] . TeamCity picks it up and the value is available as an env var in step 4 and later. Three gotchas the thread calls out: the parameter only becomes available in the NEXT step, never the one that sets it; the line must go to stdout with no extra formatting or quoting around it; and if the value contains spaces or quotes, escape them per the service-message rules or the parse silently breaks.

## When to use

You are seeing this: From your step 3 script, print this exact line to stdout: ##teamcity[setParameter name='env.PASSED_ID' value='the-id-here']. Use this skill when you run into "TeamCity: pass a value from one build step to the next with a service message".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
