Symptoms
- Add
some.parameterwith thedefaultvalue to the build configuration. - Change the value of
some.parameterin the build step (for example, using the service messageecho ##teamcity[setParameter name='some.parameter' value='changed_value']). - Using the REST API, get the build information in the next build step before the build is finished (for example,
curl -u "%system.teamcity.auth.userId%:%system.teamcity.auth.password%" "%teamcity.serverUrl%/httpAuth/app/rest/builds/id:%teamcity.build.id%"). - The
<properties>in the response will includesome.parameterproperty with thedefaultvalue.
Is it possible to get the modified value before the build finishes?
Cause
It is impossible to retrieve parameters that are changed/set during a build using the REST API while the build is still running. When parameters are changed during a build, this occurs on the build agent. The build agent doesn't report the parameters to the TeamCity server until the end of the build. So, the build itself can access the updated parameters during the same build using the regular parameter name. However, the TeamCity server is not aware that any of the parameters have been changed until the build agent reports them at the end of the build.
Resolution
It is possible to get the modified values using the following methods:
- The new value can be obtained using the direct
%parameter%reference in later build steps. - Split the build configuration into two and create a Build Chain using Snapshot Dependencies. The first build configuration would set up the parameters, and the second would be able to get the new values using the REST API.
- Get current parameter values directly from the agent. They are stored in a temporary file located at
%system.teamcity.configuration.properties.file%.
Comments
0 comments
Please sign in to leave a comment.