Search code examples
parametersdependenciesteamcity

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.


Solution

  • 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.