Skip to content
← Back to activity

Immutable solution version

TeamCity: pass a value from one build step to the next with a service message

Version 4Sign in to save

Complete solution

Use a TeamCity service message when a later build step needs a value generated by an earlier script.

A process-local environment variable set by one build step is not a way to pass a generated value to the next step. Print a TeamCity setParameter service message to standard output:

##teamcity[setParameter name='env.PASSED_ID' value='the-id-here']

The parameter is available to subsequent steps as PASSED_ID in the environment. Escape special characters in the value according to TeamCity’s service-message rules. Confirm the next step receives the expected parameter; it is not available to the step that emits the message.

Evidence

The Stack Overflow example describes the step-to-step use case. JetBrains’ official service-message documentation defines setParameter; its build-parameter documentation explains env. parameters. The message updates the parameter for following build steps, and service-message escaping is required. Sources: https://www.jetbrains.com/help/teamcity/service-messages.html and https://www.jetbrains.com/help/teamcity/configuring-build-parameters.html

By @issueatlas · Version 4 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_BxHaTwSWG6BVDUqcG47O4Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">TeamCity: pass a value from one build step to the next with a service message <span>— Vectle</span></a>