Getting dynamically updated build parameter within the build run

Answered

Hi all,

I'm setting a parameter (let's say my_param) to a running build via TC service message (##teamcity[setParameter name='my_param'...) and I want to get the new value of the parameter later but still within the run of the build via REST API (.../httpAuth/app/rest/builds/id:123/resulting-properties/my_param) but it still returns the old value. It returns the new value when the build is finished but it is too late.

Can someone please know how to do that? I'm using TC 10.x version.

Thanks in advance for your help,
Jan

10 comments
Comment actions Permalink

Hello Jan,

The changed build parameters is available in the build steps following the modifying one. resulting-properties are available only when the build finished. Why do you need to get parameters using REST API?

0
Comment actions Permalink

Hi Alina,

I'm modifying the parameter for an external service that needs to read it to make appropriate decisions based on the value. The service must read it within the build run.

Thanks,

Jan

0
Comment actions Permalink

Hi Jan,

You can get the value of the modified parameter in the next build step using %my_param% syntax.

0
Comment actions Permalink

This won't help in my case either because the step (that modifies the parameter) calls the service which in turn reads the value and then continue with other stuff.

0
Comment actions Permalink

Sorry, I do not fully understand your use case. Perhaps you can change build configuration parameter using REST API request and then change it back if needed.

0
Comment actions Permalink

This would be possible but we run several (50+) builds in parallel and if I set it on the Build Configuration level, the change will be visible to all of the concurrently running builds which is unfortunate. But if there's no better way how to change a build parameter on the fly and be able to read it in the same step via REST API, then I will have to live with that. But I don't think I want that much or do I? :)

0
Comment actions Permalink

Hello Jan,

At the moment it's not supported. Please feel free to create a feature request in our issue tracker and describe your use case. Thank you!

0
Comment actions Permalink

Hi Alina,

thanks for all your help! Issue has just been created: https://youtrack.jetbrains.com/issue/TW-47903

Jan

0
Comment actions Permalink

Possible workaround is to publish artifact using another service message: https://confluence.jetbrains.com/display/TCD10/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-artPublishingPublishingArtifactswhiletheBuildisStillinProgress

Then make your service wait till artifact is published for the build (agent does it in parallel, while the build is still running).

0
Comment actions Permalink

Thanks, Pavel! I'll give it a try.

0

Please sign in to leave a comment.