Share dynamically defined variable between build configurations

Answered

Hello,

is it possible to read a value of some parameter/variable in build step A of build configuration B which was set (I mean the variable) in build step X of build configuration Y of same project in the same (build) run? If yes, how?

Thanks in advance.

Regards, Gabriel

6 comments

Hello Gabriel,

It's possibly to read property value if build configuration depends on (snapshot or artifact) from other build configuration. For more details see the section

Also you can use REST API to get build parameters.

0

Hi Alina,

thanks for your comment. After reading the mentioned articles I came to a wonderful solution, which I wanted to achieve:

If I set an environment variable in Command Line of Build_Step_A of Build_Configuration_B of project_C in build run Z like:

echo "##teamcity[setParameter name='env.VAR_NAME' value='VAR_VALUE']"

then I can reference that variable in Command Line of Build_Step_X of Build_Configuration_Y of same project_C in the same build run Z as

%dep.<ID of Build_Configuration_B>.env.VAR_NAME%

This solution is working also if I do not add/configure beforehand the mentioned env variable (VAR_NAME)  in the "Parameters" settings of Build_Configuration_B.

Thanks. Regards,

Gabriel

1

How i can share variable between Build Steps, not configurations?

0

Similar, define variable in build step as environment variable (Runner type: Command Line):
echo "##teamcity[setParameter name='env.VAR_NAME' value='VAR_VALUE']"

then use it in other build step:
$VAR_NAME

This is how I am using, maybe exist an another way, but I am not teamcity expert :-) .

0

Gabriel, the solution referring to the dependent builds  works beautiful! thx!

0

Please sign in to leave a comment.