Setting VCS Checkout rules using parameter from dependency build

I have 2 build configurations with a snapshot dependency.

The first build has a build step which outputs a service message to set a parameter value.

When the build is finished I can see the parameter value was updated correctly.

In the dependent build I set the VCS Checkout rule to use the same parameter using %dep.BuildId.ParameterName%

I tried setting the parameter as Config, System and Env, and in all cases the parameter value was not used in the checkout rule.

The parameter value is the actual checkout rule I want applied, i.e.

+:Folder1

+:Folder2

Instead of checking out just the specific folders the entire VCS Root is checked out.

 

Update:

I created a system parameter in the containing project and this parameter is updated correctly during the build and the value is being used in the dependent build.

I also managed to update the checkout rules of the dependent build using REST API, thereby the parameter is not even necessary anymore.

However, for both the parameter and the REST API method, I can't get Teamcity to accept newlines, since the checkout rules are newline delimited.

I tried using |n (pipe), but it is only translated to a newline when updating the parameter during the build.

When I try to use this parameter to update the checkout rules the newlines are lost.

 

Update 2 (For anyone coming here searching for an answer):

After some more tinkering and web searching I got it to work by updating the checkout rules using the REST API with curl and sending the data as xml with 
 as newlines.

0
2 comments
Hi! Checkout rules are resolved before any build steps start. Otherwise, the dependent builds would be unable to reuse the dependency builds efficiently. Therefore, unfortunately, changing the parameter after the build chain is queued will not change the checkout rule.

A possible workaround that may or may not be suitable, depending on your use case, is to remove the snapshot dependency between the builds and trigger the build with checkout rules using REST API (https://www.jetbrains.com/help/teamcity/rest/start-and-cancel-builds.html) after the parameter value is set. Please note: The command that sends the REST API request must not be issued in the same build step that sets the parameter value. The new value set by the setParameter service message is available only in the subsequent build steps.

I hope that helps.
0

Hi,

 

Currently it works for me by setting the checkout rules using the REST API because the builds are usually not triggered as a build chain, but separately.

If the need arises in the future I may try your workaround.

 

Thanks.

0

Please sign in to leave a comment.