简体   繁体   中英

TeamCity : project parameters inheritance issue?

I have a TeamCity 8.0.3 project with multiple configs inside which have a common parameter (defined as a project parameter) : targetServerIP . One of these configs is a " 1 click deployment " which starts others configs by using snapshots dependencies. I've set the parameter as "prompt" so the IP is asked on each run of any configs, this is what

Problem : Individually it works fine, on each config run the IP is asked and successfully applied to the config. But when I execute the " 1 clic deployment " it also asks the IP but does not transmit it to other dependants configs (the value stays <empty> ).

My question : How can I set this parameter to be applyed to others configs when it is prompted ?

PS : I've obviously tried to set it as an env. parameter but it does not helps.

PS2 : Using templates does not seems to be a good solution for me.

There are 2 problems. One I can help with, one I am trying to solve myself just solved myself.

Your problem is how you setup the chain. The 1 click deployment "depends" on the others.

It cannot pass parameters to the other builds.
It can use parameters from the dependent builds by dep.dependent_build_configuration.paramter_name .

The fix

There are 2 things you have to do.

  1. Setup artifact dependencies
  2. Setup triggers

Build A

- Parameters

GlobalParameter

  • Display : Normal
  • Type : Text
  • Allowed Value : Not Empty

Build B

- Parameters

LocalParameter

  • Display : hidden
  • Type : Text
  • Value %dep.Build_A_GlobalParemeter%

- Snapshot Dependency

  • Depends on : "Build A"

- Triggers

  • TriggerType : Finish Build Trigger
  • Build Configuration : Build A

How this works

The artifact dependency makes the variables available via the %dep.Build_A.GlobalParameter% syntax. The Finish Build Trigger causes Build A to trigger Build B . You will have access to the parameters because they are saved from the previous build.

Until today (1 month) I've not found where the problem is (many days lost in investigation), the only workaround is to manually change value of parameter each time I need to.

Maybe there is something special to do with the XML config files ? I don't know.

In completion to @Brandon's response, you may achieve what you wanted to do in the first place using the TeamCity RestAPI you may call resulting properties on a build ID to see what properties were set on the build.

curl my.teamcityserver.com/app/rest/builds/<some-parent-build-id>/resulting-properties

search the parameter name you need in the XML and you should be able to get the value from the parent build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM